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