我正在使用使用单独链接作为冲突解决技术的哈希表。
我确实知道一般公式是 N/table_length,其中 N 是表中当前项目的数量。
我对分母有点困惑。它是数组的大小+链式元素的数量,还是只是数组的大小?
我之前使用过这个确切的函数,但只是复制并粘贴到另一个文件导致它停止工作.唯一的变化是我添加了"using namespace std".
在我的"ReadData()"函数中,我在getline(cin,data)上遇到一个错误,即没有重载函数的实例与参数列表匹配.此外,我在调用中的"数据"中收到错误,称"数据不明确".
该函数应该从文本文件中读取数据并将文本行存储在数据中以供进一步处理.这个功能确实如此,所以我只是不确定.
#include <iostream>
#include "NvraArray.h"
#include "NvraRecord.h"
#include <vector>
#include <string>
#include <ctime>
using namespace std;
// Globals
string data; // Stores the line that getline is at
vector<string> rows; // Stores the rows of data
vector<int> recordNumbersSeen; // Holds records numbers that have been checked
string strWords[24]; // Holds the individual columns of data for processing
int rowCounter = 0; // Counts the rows of data coming in
// Prototypes
// Reads the data from …Run Code Online (Sandbox Code Playgroud) 我的功能是在使用goto时给我"在'}'令牌之前预期的主要表达",我不知道为什么.
在我将它放入函数之前,这段代码按原样运行.
当我用'break'替换'goto'时它会起作用,但我需要知道为什么会这样.
void fileInputLoop(ifstream& inputFile){
do{
cout << "Enter data file name: ";
getline(cin, fileName);
previousFileName = fileName;
// The user will press enter to exit data input
if(fileName == ""){
// If no file name is entered, exit this input loop
goto skip_data_input_loop;
}else{
// Check to see if input is an existing file
inputFile.open(fileName);
if(!inputFile.is_open()){
cout << "File is not available." << endl;
}else{
// FILE IS OPEN, DO SOMETHING WITH IT
ReadData(inputFile);
inputFile.close();
}
}
// …Run Code Online (Sandbox Code Playgroud)