STL conforming hash table. More...
Classes | |
class | Iterator |
An STL iterator. More... | |
Public Types | |
typedef Iterator< T &, StaticHashTable< T, Key, Hash > & > | iterator |
typedef Iterator< const T &, const StaticHashTable< T, Key, Hash > & > | const_iterator |
typedef T | value_type |
Type of values the StaticHashTable contains. More... | |
typedef T & | reference |
Type that can be used for storing into StaticHashTable::value_type. More... | |
typedef const T & | const_reference |
Type that can be used for storing into constant. More... | |
typedef label | size_type |
The type that can represent the size of a StaticHashTable. More... | |
Public Member Functions | |
StaticHashTable (const label size=128) | |
Construct given initial table size. More... | |
StaticHashTable (Istream &, const label size=128) | |
Construct from Istream. More... | |
StaticHashTable (const StaticHashTable< T, Key, Hash > &) | |
Construct as copy. More... | |
StaticHashTable (const Xfer< StaticHashTable< T, Key, Hash >> &) | |
Construct by transferring the parameter contents. More... | |
~StaticHashTable () | |
Destructor. More... | |
label | size () const |
Return number of elements in table. More... | |
bool | empty () const |
Return true if the hash table is empty. More... | |
bool | found (const Key &key) const |
Return true if hashed entry is found in table. More... | |
iterator | find (const Key &key) |
Find and return an iterator set at the hashed entry. More... | |
const_iterator | find (const Key &key) const |
Find and return an const_iterator set at the hashed entry. More... | |
List< Key > | toc () const |
Return the table of contents. More... | |
Ostream & | printInfo (Ostream &) const |
Print information. More... | |
bool | insert (const Key &key, const T &newElmt) |
Insert a new hashed entry. More... | |
bool | set (const Key &, const T &newElmt) |
Assign a new hashed entry, overwriting existing entries. More... | |
bool | erase (const iterator &it) |
Erase an hashed entry specified by given iterator. More... | |
bool | erase (const Key &key) |
Erase an hashed entry specified by given key if in table. More... | |
void | resize (const label newSize) |
Resize the hash table for efficiency. More... | |
label | erase (const StaticHashTable< T, Key, Hash > &) |
Remove entries in the given hash table from this hash table. More... | |
void | clear () |
Clear all entries from table. More... | |
void | clearStorage () |
Clear the table entries and the table itself. More... | |
void | transfer (StaticHashTable< T, Key, Hash > &) |
Transfer the contents of the argument table into this table. More... | |
Xfer< StaticHashTable< T, Key, Hash > > | xfer () |
Transfer contents to the Xfer container. More... | |
T & | operator[] (const Key &) |
Find and return an hashed entry. More... | |
const T & | operator[] (const Key &) const |
Find and return an hashed entry. More... | |
T & | operator() (const Key &) |
Find and return an hashed entry, create it null if not present. More... | |
void | operator= (const StaticHashTable< T, Key, Hash > &) |
Assignment. More... | |
bool | operator== (const StaticHashTable< T, Key, Hash > &) const |
Equality. Two hash tables are equal if all contents of first are. More... | |
bool | operator!= (const StaticHashTable< T, Key, Hash > &) const |
The opposite of the equality operation. More... | |
iterator | begin () |
Iterator set to the beginning of the StaticHashTable. More... | |
const iterator & | end () |
Iterator set to beyond the end of the StaticHashTable. More... | |
const_iterator | cbegin () const |
const_iterator set to the beginning of the StaticHashTable More... | |
const const_iterator & | cend () const |
const_iterator set to beyond the end of the StaticHashTable More... | |
const_iterator | begin () const |
const_iterator set to the beginning of the StaticHashTable More... | |
const const_iterator & | end () const |
const_iterator set to beyond the end of the StaticHashTable More... | |
![]() | |
StaticHashTableCore () | |
Construct null. More... | |
ClassName ("StaticHashTable") | |
Define template name and debug. More... | |
Friends | |
class | Iterator< T &, StaticHashTable< T, Key, Hash > & > |
class | Iterator< const T &, const StaticHashTable< T, Key, Hash > & > |
Istream & | operator>> (Istream &, StaticHashTable< T, Key, Hash > &) |
Ostream & | operator (Ostream &, const StaticHashTable< T, Key, Hash > &) |
Additional Inherited Members | |
![]() | |
static label | canonicalSize (const label) |
Return a canonical (power-of-two) size. More... | |
STL conforming hash table.
Definition at line 58 of file StaticHashTable.H.
Definition at line 138 of file StaticHashTable.H.
typedef Iterator< const T&, const StaticHashTable<T, Key, Hash>& > const_iterator |
Definition at line 150 of file StaticHashTable.H.
typedef T value_type |
Type of values the StaticHashTable contains.
Definition at line 276 of file StaticHashTable.H.
Type that can be used for storing into StaticHashTable::value_type.
objects. This type is usually List::value_type&.
Definition at line 280 of file StaticHashTable.H.
typedef const T& const_reference |
Type that can be used for storing into constant.
StaticHashTable::value_type objects. This type is usually const StaticHashTable::value_type&.
Definition at line 285 of file StaticHashTable.H.
The type that can represent the size of a StaticHashTable.
Definition at line 288 of file StaticHashTable.H.
StaticHashTable | ( | const label | size = 128 | ) |
Construct given initial table size.
Definition at line 62 of file StaticHashTable.C.
References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.
Referenced by StaticHashTable< T, Key, Hash >::StaticHashTable().
StaticHashTable | ( | Istream & | is, |
const label | size = 128 |
||
) |
Construct from Istream.
Definition at line 34 of file StaticHashTableIO.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and Foam::operator>>().
StaticHashTable | ( | const StaticHashTable< T, Key, Hash > & | ht | ) |
Construct as copy.
Definition at line 82 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::StaticHashTable().
StaticHashTable | ( | const Xfer< StaticHashTable< T, Key, Hash >> & | ht | ) |
Construct by transferring the parameter contents.
Definition at line 97 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::transfer().
~StaticHashTable | ( | ) |
Destructor.
Definition at line 115 of file StaticHashTable.C.
|
inline |
Return number of elements in table.
Definition at line 45 of file StaticHashTableI.H.
Referenced by StaticHashTable< T, Key, Hash >::printInfo().
|
inline |
Return true if the hash table is empty.
Definition at line 52 of file StaticHashTableI.H.
References StaticHashTable< T, Key, Hash >::insert().
bool found | ( | const Key & | key | ) | const |
Return true if hashed entry is found in table.
Definition at line 122 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::find(), forAll, and InfoInFunction.
Referenced by StaticHashTable< T, Key, Hash >::erase().
Foam::StaticHashTable< T, Key, Hash >::iterator find | ( | const Key & | key | ) |
Find and return an iterator set at the hashed entry.
If not found iterator = end()
Definition at line 152 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::end(), forAll, and InfoInFunction.
Referenced by StaticHashTable< T, Key, Hash >::erase(), StaticHashTable< T, Key, Hash >::found(), and StaticHashTable< T, Key, Hash >::operator==().
Foam::StaticHashTable< T, Key, Hash >::const_iterator find | ( | const Key & | key | ) | const |
Find and return an const_iterator set at the hashed entry.
If not found iterator = end()
Definition at line 184 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::cend(), forAll, and InfoInFunction.
Foam::List< Key > toc | ( | ) | const |
Return the table of contents.
Definition at line 214 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::cbegin(), StaticHashTable< T, Key, Hash >::cend(), forAll, InfoInFunction, List< T >::setSize(), List< T >::size(), and Foam::T().
Foam::Ostream & printInfo | ( | Ostream & | os | ) | const |
Print information.
Definition at line 61 of file StaticHashTableIO.C.
References StaticHashTable< T, Key, Hash >::begin(), StaticHashTable< T, Key, Hash >::clear(), StaticHashTable< T, Key, Hash >::end(), Foam::endl(), Foam::exit(), IOstream::fatalCheck(), Foam::FatalIOError, FatalIOErrorInFunction, forAll, token::info(), StaticHashTable< T, Key, Hash >::insert(), token::isLabel(), token::isPunctuation(), token::labelToken(), Foam::nl, Foam::operator>>(), token::pToken(), Istream::putBack(), Istream::readBeginList(), Istream::readEndList(), StaticHashTable< T, Key, Hash >::resize(), s(), StaticHashTable< T, Key, Hash >::size(), and T.
|
inline |
Insert a new hashed entry.
Definition at line 60 of file StaticHashTableI.H.
Referenced by StaticHashTable< T, Key, Hash >::empty(), StaticHashTable< T, Key, Hash >::operator=(), StaticHashTable< T, Key, Hash >::printInfo(), and StaticHashTable< T, Key, Hash >::resize().
|
inline |
Assign a new hashed entry, overwriting existing entries.
Definition at line 71 of file StaticHashTableI.H.
bool erase | ( | const iterator & | it | ) |
Erase an hashed entry specified by given iterator.
Definition at line 287 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::end(), InfoInFunction, List< T >::setSize(), and List< T >::size().
Referenced by StaticHashTable< T, Key, Hash >::erase().
bool erase | ( | const Key & | key | ) |
Erase an hashed entry specified by given key if in table.
Definition at line 342 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::end(), StaticHashTable< T, Key, Hash >::erase(), and StaticHashTable< T, Key, Hash >::find().
void resize | ( | const label | newSize | ) |
Resize the hash table for efficiency.
Definition at line 380 of file StaticHashTable.C.
References Foam::abort(), StaticHashTableCore::canonicalSize(), StaticHashTable< T, Key, Hash >::cbegin(), StaticHashTable< T, Key, Hash >::cend(), Foam::FatalError, FatalErrorInFunction, InfoInFunction, StaticHashTable< T, Key, Hash >::insert(), and StaticHashTable< T, Key, Hash >::transfer().
Referenced by StaticHashTable< T, Key, Hash >::clearStorage(), and StaticHashTable< T, Key, Hash >::printInfo().
Foam::label erase | ( | const StaticHashTable< T, Key, Hash > & | rhs | ) |
Remove entries in the given hash table from this hash table.
Return the number of elements removed
Definition at line 359 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::begin(), StaticHashTable< T, Key, Hash >::end(), StaticHashTable< T, Key, Hash >::erase(), and StaticHashTable< T, Key, Hash >::found().
void clear | ( | ) |
Clear all entries from table.
Definition at line 420 of file StaticHashTable.C.
References forAll.
Referenced by StaticHashTable< T, Key, Hash >::clearStorage(), StaticHashTable< T, Key, Hash >::operator=(), StaticHashTable< T, Key, Hash >::printInfo(), and StaticHashTable< T, Key, Hash >::transfer().
void clearStorage | ( | ) |
Clear the table entries and the table itself.
Equivalent to clear() followed by resize(1)
Definition at line 433 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::clear(), StaticHashTable< T, Key, Hash >::resize(), and StaticHashTable< T, Key, Hash >::transfer().
void transfer | ( | StaticHashTable< T, Key, Hash > & | ht | ) |
Transfer the contents of the argument table into this table.
and annul the argument table.
Definition at line 442 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::clear().
Referenced by StaticHashTable< T, Key, Hash >::clearStorage(), StaticHashTable< T, Key, Hash >::resize(), and StaticHashTable< T, Key, Hash >::StaticHashTable().
|
inline |
Transfer contents to the Xfer container.
Definition at line 82 of file StaticHashTableI.H.
References Foam::xferMove().
Find and return an hashed entry.
Definition at line 91 of file StaticHashTableI.H.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and T.
Find and return an hashed entry.
Definition at line 108 of file StaticHashTableI.H.
References Foam::exit(), Foam::FatalError, and FatalErrorInFunction.
Find and return an hashed entry, create it null if not present.
Definition at line 126 of file StaticHashTableI.H.
void operator= | ( | const StaticHashTable< T, Key, Hash > & | rhs | ) |
Assignment.
Definition at line 469 of file StaticHashTable.C.
References Foam::abort(), StaticHashTable< T, Key, Hash >::cbegin(), StaticHashTable< T, Key, Hash >::cend(), StaticHashTable< T, Key, Hash >::clear(), Foam::FatalError, FatalErrorInFunction, and StaticHashTable< T, Key, Hash >::insert().
bool operator== | ( | const StaticHashTable< T, Key, Hash > & | rhs | ) | const |
Equality. Two hash tables are equal if all contents of first are.
also in second and vice versa.
Definition at line 507 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::cbegin(), StaticHashTable< T, Key, Hash >::cend(), and StaticHashTable< T, Key, Hash >::find().
Referenced by StaticHashTable< T, Key, Hash >::operator!=().
bool operator!= | ( | const StaticHashTable< T, Key, Hash > & | rhs | ) | const |
The opposite of the equality operation.
Definition at line 529 of file StaticHashTable.C.
References StaticHashTable< T, Key, Hash >::operator==().
|
inline |
Iterator set to the beginning of the StaticHashTable.
Definition at line 337 of file StaticHashTableI.H.
References forAll, and Foam::Info.
Referenced by StaticHashTable< T, Key, Hash >::erase(), and StaticHashTable< T, Key, Hash >::printInfo().
|
inline |
Iterator set to beyond the end of the StaticHashTable.
Definition at line 361 of file StaticHashTableI.H.
Referenced by StaticHashTable< T, Key, Hash >::erase(), StaticHashTable< T, Key, Hash >::find(), and StaticHashTable< T, Key, Hash >::printInfo().
|
inline |
const_iterator set to the beginning of the StaticHashTable
Definition at line 369 of file StaticHashTableI.H.
References forAll, and Foam::Info.
Referenced by StaticHashTable< T, Key, Hash >::operator=(), StaticHashTable< T, Key, Hash >::operator==(), StaticHashTable< T, Key, Hash >::resize(), and StaticHashTable< T, Key, Hash >::toc().
|
inline |
const_iterator set to beyond the end of the StaticHashTable
Definition at line 393 of file StaticHashTableI.H.
Referenced by StaticHashTable< T, Key, Hash >::find(), StaticHashTable< T, Key, Hash >::operator=(), StaticHashTable< T, Key, Hash >::operator==(), StaticHashTable< T, Key, Hash >::resize(), and StaticHashTable< T, Key, Hash >::toc().
|
inline |
const_iterator set to the beginning of the StaticHashTable
Definition at line 401 of file StaticHashTableI.H.
|
inline |
const_iterator set to beyond the end of the StaticHashTable
Definition at line 409 of file StaticHashTableI.H.
|
friend |
Definition at line 159 of file StaticHashTable.H.
|
friend |
Definition at line 165 of file StaticHashTable.H.
|
friend |