Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Chain class with a given modulus. More...
Public Member Functions | |
hash_chain (int mod) | |
Construct a new chain object. More... | |
void | add (int x, int h) |
create and add a new node with a give value and at a given height More... | |
void | display () |
Display the chain. More... | |
virtual int | hash (int x) const |
Compute the hash of a value for current chain. More... | |
bool | find (int x, int h) const |
Find if a value and corresponding hash exist. More... | |
Private Types | |
using | Node = Node { int data{} |
data stored in the node | |
Private Attributes | |
std::shared_ptr< struct Node > | next |
pointer to the next node | |
std::vector< std::shared_ptr< Node > > | head |
array of nodes | |
int | _mod |
modulus of the class | |
Chain class with a given modulus.
|
inlineexplicit |
Construct a new chain object.
mod | modulus of the chain |
|
inline |
create and add a new node with a give value and at a given height
x | value at the new node |
h | height of the node |
|
inline |
|
inline |
Find if a value and corresponding hash exist.
x | value to search for |
h | corresponding hash key |
true
if element found false
if element not found
|
inlinevirtual |