Base class for hashing with chaining and table doubling. More...
#include <ogdf/basic/Hashing.h>
Public Member Functions | |
HashingBase (const HashingBase &H) | |
Copy constructor. | |
HashingBase (int minTableSize) | |
Creates a hash table with minimum table size minTableSize . | |
virtual | ~HashingBase () |
Destruction. | |
void | clear () |
Removes all elements from the hash table. | |
void | del (HashElementBase *pElement) |
Removes the element pElement from the hash table. | |
int | empty () const |
Returns if the hash table is empty. | |
HashElementBase * | firstElement (HashElementBase ***pList) const |
Returns the first element in the list of all elements in the hash table. | |
HashElementBase * | firstListElement (size_t hashValue) const |
Returns the first element in the list for elements with hash value hashValue . | |
void | insert (HashElementBase *pElement) |
Inserts a new element pElement into the hash table. | |
HashElementBase * | nextElement (HashElementBase ***pList, HashElementBase *pElement) const |
Returns the successor of pElement in the list of all elements in the hash table. | |
HashingBase & | operator= (const HashingBase &H) |
Assignment operator. | |
void | resize (int newTableSize) |
Resizes the hash table to newTableSize . | |
int | size () const |
Returns the number of elements in the hash table. | |
Protected Member Functions | |
virtual HashElementBase * | copy (HashElementBase *pElement) const =0 |
Called to create a copy of the element pElement . | |
virtual void | destroy (HashElementBase *pElement)=0 |
Called to delete hash element. | |
void | destroyAll () |
Deletes all elements in hash table (but does not free m_table!). | |
Protected Attributes | |
int | m_count |
The current number of elements. | |
int | m_hashMask |
The current table size minus one. | |
int | m_minTableSize |
The minimal table size. | |
HashElementBase ** | m_table |
The hash table (an array of lists). | |
int | m_tableSize |
The current table size. | |
int | m_tableSizeHigh |
The maximal number of elements at this table size. | |
int | m_tableSizeLow |
The minimal number of elements at this table size. | |
Private Member Functions | |
void | copyAll (const HashingBase &H) |
Copies all elements from H to this hash table. | |
void | init (int tableSize) |
Initializes the table for given table size. | |
Base class for hashing with chaining and table doubling.
The actual hashing is provided by the parameterized class Hashing<K,I> which derives from HashingBase.
|
explicit |
Creates a hash table with minimum table size minTableSize
.
ogdf::HashingBase::HashingBase | ( | const HashingBase & | H | ) |
Copy constructor.
|
virtual |
Destruction.
void ogdf::HashingBase::clear | ( | ) |
Removes all elements from the hash table.
|
protectedpure virtual |
Called to create a copy of the element pElement
.
Implemented in ogdf::Hashing< E, PrioritizedQueue< E, P, std::less< P >, PairingHeap >::Handle, DefHashFunc< E > >, ogdf::Hashing< I, E, DefHashFunc< I > >, ogdf::Hashing< int, int, DefHashFunc< int > >, ogdf::Hashing< int, ogdf::ClusterElement, DefHashFunc< int > >, ogdf::Hashing< int, ogdf::ListIteratorBase< int >, DefHashFunc< int > >, ogdf::Hashing< K, I, DefHashFunc< K > >, ogdf::Hashing< ogdf::EdgeElement, PrioritizedQueue< ogdf::EdgeElement, TCap, std::less< TCap >, PairingHeap >::Handle, DefHashFunc< ogdf::EdgeElement > >, ogdf::Hashing< ogdf::List< ogdf::NodeElement >, ogdf::steiner_tree::FullComponentGeneratorDreyfusWagner::DWMData, ogdf::steiner_tree::FullComponentGeneratorDreyfusWagner::SortedNodeListHashFunc >, ogdf::Hashing< ogdf::List< ogdf::NodeElement >, ogdf::steiner_tree::FullComponentGeneratorDreyfusWagnerWithoutMatrix::DWMData, ogdf::steiner_tree::FullComponentGeneratorDreyfusWagnerWithoutMatrix::SortedNodeListHashFunc >, ogdf::Hashing< std::string, ogdf::NodeElement, DefHashFunc< std::string > >, ogdf::Hashing< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > >, ogdf::Hashing< Tuple2< I1_, I2_ >, E_, HashFuncTuple< I1_, I2_, DefHashFunc< I1_ >, DefHashFunc< I2_ > > >, ogdf::Hashing< Tuple2< int, int >, ogdf::List< ogdf::EdgeElement >, HashFuncTuple< int, int, DefHashFunc< int >, DefHashFunc< int > > >, and ogdf::Hashing< K, I, H >.
|
private |
Copies all elements from H
to this hash table.
void ogdf::HashingBase::del | ( | HashElementBase * | pElement | ) |
Removes the element pElement
from the hash table.
|
protectedpure virtual |
Called to delete hash element.
This must be done in Hashing<K,I> since only this class knows the actual element type; alternatively, HashElementBase could have a virtual destructor.
Implemented in ogdf::Hashing< E, PrioritizedQueue< E, P, std::less< P >, PairingHeap >::Handle, DefHashFunc< E > >, ogdf::Hashing< I, E, DefHashFunc< I > >, ogdf::Hashing< int, int, DefHashFunc< int > >, ogdf::Hashing< int, ogdf::ClusterElement, DefHashFunc< int > >, ogdf::Hashing< int, ogdf::ListIteratorBase< int >, DefHashFunc< int > >, ogdf::Hashing< K, I, DefHashFunc< K > >, ogdf::Hashing< ogdf::EdgeElement, PrioritizedQueue< ogdf::EdgeElement, TCap, std::less< TCap >, PairingHeap >::Handle, DefHashFunc< ogdf::EdgeElement > >, ogdf::Hashing< ogdf::List< ogdf::NodeElement >, ogdf::steiner_tree::FullComponentGeneratorDreyfusWagner::DWMData, ogdf::steiner_tree::FullComponentGeneratorDreyfusWagner::SortedNodeListHashFunc >, ogdf::Hashing< ogdf::List< ogdf::NodeElement >, ogdf::steiner_tree::FullComponentGeneratorDreyfusWagnerWithoutMatrix::DWMData, ogdf::steiner_tree::FullComponentGeneratorDreyfusWagnerWithoutMatrix::SortedNodeListHashFunc >, ogdf::Hashing< std::string, ogdf::NodeElement, DefHashFunc< std::string > >, ogdf::Hashing< Tuple2< I1, I2 >, E, HashFuncTuple< I1, I2, DefHashFunc< I1 >, DefHashFunc< I2 > > >, ogdf::Hashing< Tuple2< I1_, I2_ >, E_, HashFuncTuple< I1_, I2_, DefHashFunc< I1_ >, DefHashFunc< I2_ > > >, ogdf::Hashing< Tuple2< int, int >, ogdf::List< ogdf::EdgeElement >, HashFuncTuple< int, int, DefHashFunc< int >, DefHashFunc< int > > >, and ogdf::Hashing< K, I, H >.
|
protected |
Deletes all elements in hash table (but does not free m_table!).
|
inline |
HashElementBase * ogdf::HashingBase::firstElement | ( | HashElementBase *** | pList | ) | const |
Returns the first element in the list of all elements in the hash table.
This function is used by hash iterators for iterating over all elements in the hash table.
pList | is assigned the list containing the first element. |
nullptr
if hash table is empty.
|
inline |
Returns the first element in the list for elements with hash value hashValue
.
This is the list m_table[\ hashValue & m_hashMask].
void ogdf::HashingBase::insert | ( | HashElementBase * | pElement | ) |
Inserts a new element pElement
into the hash table.
HashElementBase * ogdf::HashingBase::nextElement | ( | HashElementBase *** | pList, |
HashElementBase * | pElement | ||
) | const |
Returns the successor of pElement
in the list of all elements in the hash table.
This function is used by hash iterators for iterating over all elements in the hash table.
pList | is assigned the list containing the first element. |
pElement | points to an element in the has table. |
nullptr
if hash table is empty. HashingBase & ogdf::HashingBase::operator= | ( | const HashingBase & | H | ) |
Assignment operator.
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |