TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
An implementation of hash table using double hashing algorithm. More...
Classes | |
struct | Entry |
Typedefs | |
using | Entry = struct Entry |
Functions | |
bool | putProber (const Entry &entry, int key) |
bool | searchingProber (const Entry &entry, int key) |
void | add (int key) |
size_t | hashFxn (int key) |
Hash a key. Uses the STL library's std::hash() function. | |
size_t | otherHashFxn (int key) |
Used for second hash function. | |
int | doubleHash (int key, bool searching) |
Performs double hashing to resolve collisions. | |
void | display () |
void | rehash () |
void | remove (int key) |
void | addInfo (int key) |
void | removalInfo (int key) |
Variables | |
int | notPresent |
std::vector< Entry > | table |
int | totalSize |
int | tomb = -1 |
int | size |
bool | rehashing |
An implementation of hash table using double hashing algorithm.
using double_hashing::Entry = struct Entry |
Definition at line 22 of file double_hash_hash_table.cpp.
void double_hashing::add | ( | int | key | ) |
Checks for load factor here
key | key value to add to the table |
Definition at line 185 of file double_hash_hash_table.cpp.
void double_hashing::addInfo | ( | int | key | ) |
Information about the adding process
key | key value to add to table |
Definition at line 212 of file double_hash_hash_table.cpp.
void double_hashing::display | ( | ) |
Displays the table
Definition at line 143 of file double_hash_hash_table.cpp.
int double_hashing::doubleHash | ( | int | key, |
bool | searching ) |
Performs double hashing to resolve collisions.
key | key value to apply double-hash on |
searching | true to check for conflicts |
Definition at line 71 of file double_hash_hash_table.cpp.
size_t double_hashing::hashFxn | ( | int | key | ) |
Hash a key. Uses the STL library's std::hash()
function.
key | value to hash |
Definition at line 47 of file double_hash_hash_table.cpp.
size_t double_hashing::otherHashFxn | ( | int | key | ) |
Used for second hash function.
key | key value to hash |
Definition at line 58 of file double_hash_hash_table.cpp.
bool double_hashing::putProber | ( | const Entry & | entry, |
int | key ) |
Finds empty spot in a vector
entry | vector to search in |
key | key to search for |
true
if key is not present or is a toumb
false
is already occupied Definition at line 120 of file double_hash_hash_table.cpp.
void double_hashing::rehash | ( | ) |
Rehashes the table into a bigger table
Definition at line 161 of file double_hash_hash_table.cpp.
void double_hashing::removalInfo | ( | int | key | ) |
Information about removal process
key | key value to remove from table |
Definition at line 227 of file double_hash_hash_table.cpp.
void double_hashing::remove | ( | int | key | ) |
Removes key. Leaves tombstone upon removal.
key | key value to remove |
Definition at line 199 of file double_hash_hash_table.cpp.
bool double_hashing::searchingProber | ( | const Entry & | entry, |
int | key ) |
Looks for a matching key
entry | vector to search in |
key | key value to search |
true
if found false
if not found Definition at line 133 of file double_hash_hash_table.cpp.
int double_hashing::notPresent |
Definition at line 28 of file double_hash_hash_table.cpp.
bool double_hashing::rehashing |
Definition at line 33 of file double_hash_hash_table.cpp.
int double_hashing::size |
Definition at line 32 of file double_hash_hash_table.cpp.
std::vector<Entry> double_hashing::table |
Definition at line 29 of file double_hash_hash_table.cpp.
int double_hashing::tomb = -1 |
Definition at line 31 of file double_hash_hash_table.cpp.
int double_hashing::totalSize |
Definition at line 30 of file double_hash_hash_table.cpp.