40# define NumItems 10000
47static size_t hashFct(
const unsigned & key)
57 unsigned long currSize = table.
capacity();
58 cout <<
"Resizing hash table from " << currSize <<
" ... ";
65 cout <<
"Table length = " << table.
capacity() << endl
67 <<
"Num items = " << table.
size() << endl;
70int main(
int argc,
char *argv[])
75 unsigned int t = std::time(NULL);
80 n = std::stoi(argv[1]);
83 t = std::stoi(argv[2]);
92 cout <<
"n must be positive" << endl;
98 cout << argv[0] <<
" " << n <<
" " << t << endl;
103 unsigned int foundCounter = 0;
105 for (i = 0; i < n/2; i++)
112 [[maybe_unused]]
const auto inserted = table.
insert(
keys[i], i);
113 assert(inserted != NULL);
119 cout << foundCounter <<
" duplicated numbers" << endl;
121 assert( table.
size() + foundCounter == n/2);
124 for (i = n/2; i < n; i++)
136 for (i = 0; i < n; i++)
Dynamic hash table mapping keys to records with separate chaining.
Record * search(const Key &key)
Search for a key in the table.
void remove(Record *record)
Remove an entry from the table.
Record * insert(const Key &key, const Record &record)
Insert a key-record pair into the table.
const size_t & get_num_busy_slots() const noexcept
Returns the number of occupied entries in the array.
const size_t & size() const noexcept
Returns the number of elements contained in the table.
const size_t & capacity() const noexcept
Returns the table capacity.
size_t resize(const size_t new_size)
Resizes the table to new_size lists and places every bucket again.
and
Check uniqueness with explicit hash + equality functors.
bool check_primes_database()
Verify the order of the prime database.
DynLhashTable< unsigned, unsigned > HTable
static size_t hashFct(const unsigned &key)
static void testResize(HTable &table)
static void printPars(const HTable &table)
Lazy and scalable dynamic array implementation.
Dynamic hash table mapping keys to records with separate chaining.