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... | |
Public Member Functions inherited from ListHashTableCore | |
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 Public Member Functions inherited from ListHashTableCore | |
static label | canonicalSize (const label) |
Return a canonical (power-of-two) size. More... | |
STL conforming hash table using contiguous lists rather than linked lists.
Note: Is slower to insert than the standard HashTable, but should be more memory efficient and faster to access.
Definition at line 104 of file ListHashTable.H.
Definition at line 142 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, FatalErrorInFunction, and ListHashTable< T, Key, Hash >::size().
ListHashTable | ( | Istream & | is, |
const label | size = 128 |
||
) |
Construct from Istream.
Definition at line 33 of file ListHashTableIO.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, ListHashTable< T, Key, Hash >::operator>>, and ListHashTable< T, Key, Hash >::size().
ListHashTable | ( | const ListHashTable< T, Key, Hash > & | ht | ) |
Copy constructor.
Definition at line 81 of file ListHashTable.C.
ListHashTable | ( | ListHashTable< T, Key, Hash > && | ht | ) |
Move constructor.
Definition at line 96 of file ListHashTable.C.
References ListHashTable< T, Key, Hash >::transfer().
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 >::cbegin(), ListHashTable< T, Key, Hash >::ListHashTable(), and ListHashTable< T, Key, Hash >::Iterator< T &, ListHashTable< T, word, string::hash > & >::operator=().
|
inline |
Return true if the hash table is empty.
Definition at line 49 of file ListHashTableI.H.
bool found | ( | const Key & | key | ) | const |
Return true if hashed entry is found in table.
Definition at line 122 of file ListHashTable.C.
References 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 151 of file ListHashTable.C.
References forAll, and InfoInFunction.
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 183 of file ListHashTable.C.
References forAll, and InfoInFunction.
Foam::List< Key > toc |
Return the table of contents.
Definition at line 214 of file ListHashTable.C.
Foam::Ostream & printInfo | ( | Ostream & | os | ) | const |
Print information.
Definition at line 61 of file ListHashTableIO.C.
References Foam::count(), Foam::endl(), and forAll.
|
inline |
Insert a new hashed entry.
Definition at line 56 of file ListHashTableI.H.
Referenced by ListHashTable< T, Key, Hash >::resize().
|
inline |
Assign a new hashed entry, overwriting existing entries.
Definition at line 67 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 InfoInFunction, List< T >::setSize(), and List< T >::size().
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 erase().
void resize | ( | const label | newSize | ) |
Resize the hash table for efficiency.
Definition at line 380 of file ListHashTable.C.
References Foam::abort(), ListHashTableCore::canonicalSize(), Foam::FatalError, FatalErrorInFunction, InfoInFunction, and ListHashTable< T, Key, Hash >::insert().
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 358 of file ListHashTable.C.
References Foam::count(), erase(), and ListHashTable< T, Key, Hash >::found().
void clear |
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 clear(), and resize().
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 441 of file ListHashTable.C.
References clear().
Referenced by ListHashTable< T, Key, Hash >::ListHashTable().
Find and return an hashed entry.
Definition at line 80 of file ListHashTableI.H.
References Foam::exit(), Foam::FatalError, and FatalErrorInFunction.
Find and return an hashed entry.
Definition at line 96 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.
References Foam::vtkWriteOps::insert(), and Foam::T().
void operator= | ( | const ListHashTable< T, Key, Hash > & | rhs | ) |
Assignment operator.
Definition at line 468 of file ListHashTable.C.
References Foam::abort(), clear(), Foam::FatalError, FatalErrorInFunction, and Foam::vtkWriteOps::insert().
void operator= | ( | ListHashTable< T, Key, Hash > && | rhs | ) |
Move assignment operator.
Definition at line 507 of file ListHashTable.C.
References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.
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 525 of file ListHashTable.C.
Referenced by ListHashTable< T, Key, Hash >::Iterator< TRef, TableRef >::operator!=().
bool operator!= | ( | const ListHashTable< T, Key, Hash > & | rhs | ) | const |
The opposite of the equality operation.
Definition at line 547 of file ListHashTable.C.
References Foam::operator==().
|
inline |
Iterator set to the beginning of the ListHashTable.
Definition at line 326 of file ListHashTableI.H.
References forAll.
|
inline |
Iterator set to beyond the end of the ListHashTable.
Definition at line 350 of file ListHashTableI.H.
|
inline |
const_iterator set to the beginning of the ListHashTable
Definition at line 358 of file ListHashTableI.H.
References forAll, Foam::Info, and ListHashTable< T, Key, Hash >::size().
Referenced by ListHashTable< T, Key, Hash >::begin().
|
inline |
const_iterator set to beyond the end of the ListHashTable
Definition at line 382 of file ListHashTableI.H.
|
inline |
const_iterator set to the beginning of the ListHashTable
Definition at line 390 of file ListHashTableI.H.
References ListHashTable< T, Key, Hash >::cbegin().
|
inline |
const_iterator set to beyond the end of the ListHashTable
Definition at line 398 of file ListHashTableI.H.
|
friend |
Definition at line 148 of file ListHashTable.H.
|
friend |
Definition at line 148 of file ListHashTable.H.
Referenced by ListHashTable< T, Key, Hash >::ListHashTable().
|
friend |