STL conforming hash table using contiguous lists rather than linked lists. More...
Classes | |
class | Iterator |
An STL iterator. More... | |
Public Types | |
typedef Iterator< T &, ListHashTable< T, Key, Hash > &> | iterator |
typedef Iterator< const T &, const ListHashTable< T, Key, Hash > &> | const_iterator |
typedef T | value_type |
Type of values the ListHashTable contains. More... | |
typedef T & | reference |
Type that can be used for storing into ListHashTable::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 ListHashTable. More... | |
Public Member Functions | |
ListHashTable (const label size=128) | |
Construct given initial table size. More... | |
ListHashTable (Istream &, const label size=128) | |
Construct from Istream. More... | |
ListHashTable (const ListHashTable< T, Key, Hash > &) | |
Copy constructor. More... | |
ListHashTable (ListHashTable< T, Key, Hash > &&) | |
Move constructor. More... | |
~ListHashTable () | |
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 ListHashTable< 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 (ListHashTable< T, Key, Hash > &) |
Transfer the contents of the argument table into this table. 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 ListHashTable< T, Key, Hash > &) |
Assignment operator. More... | |
void | operator= (ListHashTable< T, Key, Hash > &&) |
Move assignment operator. More... | |
bool | operator== (const ListHashTable< T, Key, Hash > &) const |
Equality. Two hash tables are equal if all contents of first are. More... | |
bool | operator!= (const ListHashTable< T, Key, Hash > &) const |
The opposite of the equality operation. More... | |
iterator | begin () |
Iterator set to the beginning of the ListHashTable. More... | |
const iterator & | end () |
Iterator set to beyond the end of the ListHashTable. More... | |
const_iterator | cbegin () const |
const_iterator set to the beginning of the ListHashTable More... | |
const const_iterator & | cend () const |
const_iterator set to beyond the end of the ListHashTable More... | |
const_iterator | begin () const |
const_iterator set to the beginning of the ListHashTable More... | |
const const_iterator & | end () const |
const_iterator set to beyond the end of the ListHashTable More... | |
![]() | |
ListHashTableCore () | |
Construct null. More... | |
ClassName ("ListHashTable") | |
Define template name and debug. More... | |
Friends | |
class | Iterator< T &, ListHashTable< T, Key, Hash > &> |
class | Iterator< const T &, const ListHashTable< T, Key, Hash > &> |
Istream & | operator>> (Istream &, ListHashTable< T, Key, Hash > &) |
Ostream & | operator (Ostream &, const ListHashTable< T, Key, Hash > &) |
Additional Inherited Members | |
![]() | |
static label | canonicalSize (const label) |
Return a canonical (power-of-two) size. More... | |
STL conforming hash table using contiguous lists rather than linked lists.
Definition at line 56 of file ListHashTable.H.
Definition at line 136 of file ListHashTable.H.
typedef Iterator< const T&, const ListHashTable<T, Key, Hash>& > const_iterator |
Definition at line 148 of file ListHashTable.H.
typedef T value_type |
Type of values the ListHashTable contains.
Definition at line 274 of file ListHashTable.H.
Type that can be used for storing into ListHashTable::value_type.
objects. This type is usually List::value_type&.
Definition at line 278 of file ListHashTable.H.
typedef const T& const_reference |
Type that can be used for storing into constant.
ListHashTable::value_type objects. This type is usually const ListHashTable::value_type&.
Definition at line 283 of file ListHashTable.H.
The type that can represent the size of a ListHashTable.
Definition at line 286 of file ListHashTable.H.
ListHashTable | ( | const label | size = 128 | ) |
Construct given initial table size.
Definition at line 62 of file ListHashTable.C.
References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.
Referenced by ListHashTable< T, Key, Hash >::ListHashTable().
ListHashTable | ( | Istream & | is, |
const label | size = 128 |
||
) |
Construct from Istream.
Definition at line 34 of file ListHashTableIO.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and Foam::operator>>().
ListHashTable | ( | const ListHashTable< T, Key, Hash > & | ht | ) |
Copy constructor.
Definition at line 82 of file ListHashTable.C.
References ListHashTable< T, Key, Hash >::ListHashTable().
ListHashTable | ( | ListHashTable< T, Key, Hash > && | ht | ) |
Move constructor.
Definition at line 97 of file ListHashTable.C.
References ListHashTable< T, Key, Hash >::transfer().
~ListHashTable | ( | ) |
Destructor.
Definition at line 115 of file ListHashTable.C.
|
inline |
Return number of elements in table.
Definition at line 42 of file ListHashTableI.H.
Referenced by ListHashTable< T, Key, Hash >::printInfo().
|
inline |
Return true if the hash table is empty.
Definition at line 49 of file ListHashTableI.H.
References ListHashTable< 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 ListHashTable.C.
References ListHashTable< T, Key, Hash >::find(), forAll, and InfoInFunction.
Referenced by ListHashTable< T, Key, Hash >::erase().
Foam::ListHashTable< 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 ListHashTable.C.
References ListHashTable< T, Key, Hash >::end(), forAll, and InfoInFunction.
Referenced by ListHashTable< T, Key, Hash >::erase(), ListHashTable< T, Key, Hash >::found(), and ListHashTable< T, Key, Hash >::operator==().
Foam::ListHashTable< 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 ListHashTable.C.
References ListHashTable< T, Key, Hash >::cend(), forAll, and InfoInFunction.
Foam::List< Key > toc | ( | ) | const |
Return the table of contents.
Definition at line 214 of file ListHashTable.C.
References ListHashTable< T, Key, Hash >::cbegin(), ListHashTable< 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 ListHashTableIO.C.
References ListHashTable< T, Key, Hash >::begin(), ListHashTable< T, Key, Hash >::clear(), ListHashTable< T, Key, Hash >::end(), Foam::endl(), Foam::exit(), IOstream::fatalCheck(), Foam::FatalIOError, FatalIOErrorInFunction, forAll, token::info(), ListHashTable< T, Key, Hash >::insert(), token::isLabel(), token::isPunctuation(), token::labelToken(), Foam::nl, Foam::operator>>(), token::pToken(), Istream::putBack(), Istream::readBeginList(), Istream::readEndList(), ListHashTable< T, Key, Hash >::resize(), s(), ListHashTable< T, Key, Hash >::size(), and T.
|
inline |
Insert a new hashed entry.
Definition at line 57 of file ListHashTableI.H.
Referenced by ListHashTable< T, Key, Hash >::empty(), ListHashTable< T, Key, Hash >::operator=(), ListHashTable< T, Key, Hash >::printInfo(), and ListHashTable< T, Key, Hash >::resize().
|
inline |
Assign a new hashed entry, overwriting existing entries.
Definition at line 68 of file ListHashTableI.H.
bool erase | ( | const iterator & | it | ) |
Erase an hashed entry specified by given iterator.
Definition at line 287 of file ListHashTable.C.
References ListHashTable< T, Key, Hash >::end(), InfoInFunction, List< T >::setSize(), and List< T >::size().
Referenced by ListHashTable< 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 ListHashTable.C.
References ListHashTable< T, Key, Hash >::end(), ListHashTable< T, Key, Hash >::erase(), and ListHashTable< T, Key, Hash >::find().
void resize | ( | const label | newSize | ) |
Resize the hash table for efficiency.
Definition at line 380 of file ListHashTable.C.
References Foam::abort(), ListHashTableCore::canonicalSize(), ListHashTable< T, Key, Hash >::cbegin(), ListHashTable< T, Key, Hash >::cend(), Foam::FatalError, FatalErrorInFunction, InfoInFunction, ListHashTable< T, Key, Hash >::insert(), and ListHashTable< T, Key, Hash >::transfer().
Referenced by ListHashTable< T, Key, Hash >::clearStorage(), and ListHashTable< T, Key, Hash >::printInfo().
Foam::label erase | ( | const ListHashTable< 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 ListHashTable.C.
References ListHashTable< T, Key, Hash >::begin(), ListHashTable< T, Key, Hash >::end(), ListHashTable< T, Key, Hash >::erase(), and ListHashTable< T, Key, Hash >::found().
void clear | ( | ) |
Clear all entries from table.
Definition at line 420 of file ListHashTable.C.
References forAll.
Referenced by ListHashTable< T, Key, Hash >::clearStorage(), ListHashTable< T, Key, Hash >::operator=(), ListHashTable< T, Key, Hash >::printInfo(), and ListHashTable< 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 ListHashTable.C.
References ListHashTable< T, Key, Hash >::clear(), ListHashTable< T, Key, Hash >::resize(), and ListHashTable< T, Key, Hash >::transfer().
void transfer | ( | ListHashTable< 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 ListHashTable.C.
References ListHashTable< T, Key, Hash >::clear().
Referenced by ListHashTable< T, Key, Hash >::clearStorage(), ListHashTable< T, Key, Hash >::ListHashTable(), ListHashTable< T, Key, Hash >::operator=(), and ListHashTable< T, Key, Hash >::resize().
Find and return an hashed entry.
Definition at line 80 of file ListHashTableI.H.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and T.
Find and return an hashed entry.
Definition at line 97 of file ListHashTableI.H.
References Foam::exit(), Foam::FatalError, and FatalErrorInFunction.
Find and return an hashed entry, create it null if not present.
Definition at line 115 of file ListHashTableI.H.
void operator= | ( | const ListHashTable< T, Key, Hash > & | rhs | ) |
Assignment operator.
Definition at line 469 of file ListHashTable.C.
References Foam::abort(), ListHashTable< T, Key, Hash >::cbegin(), ListHashTable< T, Key, Hash >::cend(), ListHashTable< T, Key, Hash >::clear(), Foam::FatalError, FatalErrorInFunction, and ListHashTable< T, Key, Hash >::insert().
void operator= | ( | ListHashTable< T, Key, Hash > && | rhs | ) |
Move assignment operator.
Definition at line 508 of file ListHashTable.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and ListHashTable< T, Key, Hash >::transfer().
bool operator== | ( | const ListHashTable< 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 526 of file ListHashTable.C.
References ListHashTable< T, Key, Hash >::cbegin(), ListHashTable< T, Key, Hash >::cend(), and ListHashTable< T, Key, Hash >::find().
Referenced by ListHashTable< T, Key, Hash >::operator!=().
bool operator!= | ( | const ListHashTable< T, Key, Hash > & | rhs | ) | const |
The opposite of the equality operation.
Definition at line 548 of file ListHashTable.C.
References ListHashTable< T, Key, Hash >::operator==().
|
inline |
Iterator set to the beginning of the ListHashTable.
Definition at line 326 of file ListHashTableI.H.
References forAll, and Foam::Info.
Referenced by ListHashTable< T, Key, Hash >::erase(), and ListHashTable< T, Key, Hash >::printInfo().
|
inline |
Iterator set to beyond the end of the ListHashTable.
Definition at line 350 of file ListHashTableI.H.
Referenced by ListHashTable< T, Key, Hash >::erase(), ListHashTable< T, Key, Hash >::find(), and ListHashTable< T, Key, Hash >::printInfo().
|
inline |
const_iterator set to the beginning of the ListHashTable
Definition at line 358 of file ListHashTableI.H.
References forAll, and Foam::Info.
Referenced by ListHashTable< T, Key, Hash >::operator=(), ListHashTable< T, Key, Hash >::operator==(), ListHashTable< T, Key, Hash >::resize(), and ListHashTable< T, Key, Hash >::toc().
|
inline |
const_iterator set to beyond the end of the ListHashTable
Definition at line 382 of file ListHashTableI.H.
Referenced by ListHashTable< T, Key, Hash >::find(), ListHashTable< T, Key, Hash >::operator=(), ListHashTable< T, Key, Hash >::operator==(), ListHashTable< T, Key, Hash >::resize(), and ListHashTable< T, Key, Hash >::toc().
|
inline |
const_iterator set to the beginning of the ListHashTable
Definition at line 390 of file ListHashTableI.H.
|
inline |
const_iterator set to beyond the end of the ListHashTable
Definition at line 398 of file ListHashTableI.H.
|
friend |
Definition at line 157 of file ListHashTable.H.
|
friend |
Definition at line 163 of file ListHashTable.H.
|
friend |