The problem of insert term.
JYT-ad opened this issue · 1 comments
JYT-ad commented
I try to use the function KukuTable::insert with my txt file, but it cannot work.
Could you tell me the reason
The error is as follow.
/home/jiang/My_Project/cuckoo_hash_table/cuckoo_hash.cpp: In function ‘int main(int, char**)’:
/home/jiang/My_Project/cuckoo_hash_table/cuckoo_hash.cpp:49:31: error: cannot call member function ‘bool kuku::KukuTable::insert(kuku::item_type)’ without object
49 | KukuTable::insert(term);
| ^
int main(int argc, char *argv[])
{
auto table_size = static_cast<table_size_type>(atoi(argv[1]));
auto stash_size = static_cast<table_size_type>(atoi(argv[2]));
uint8_t loc_func_count = static_cast<uint8_t>(atoi(argv[3]));
item_type loc_func_seed = make_random_item();
uint64_t max_probe = static_cast<uint64_t>(atoi(argv[4]));
item_type empty_item = make_item(0, 0);
KukuTable table(table_size, stash_size, loc_func_count, loc_func_seed, max_probe, empty_item);
ifstream in("test.txt");
string line;
char p[64];
if (!in)
{
cout << "File cannot open!" << endl;
}
**while (getline(in, line))
{
strcpy(p, line.c_str());
item_type term= make_item(reinterpret_cast<unsigned char*>(p));
KukuTable::insert(term);
}**
print_table(table);
return 0;
}
kiromaru commented
Sorry for the late reply. You might have solved this already, but the problem is that the insert method should be called on your "table" object:
table.insert(term);