STL conforming hash table. More...
Data Structures | |
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 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... | |
Data Fields | |
const typedef T & | const_reference |
Type that can be used for storing into constant. More... | |
Private Member Functions | |
label | hashKeyIndex (const Key &) const |
Return the hash index of the Key within the current table size. More... | |
bool | set (const Key &, const T &newElmt, bool protect) |
Assign a new hashed entry to a possibly already existing key. More... | |
Static Private Member Functions | |
static label | canonicalSize (const label) |
Return a canonical (power-of-two) size. More... | |
Private Attributes | |
List< List< Key > > | keys_ |
The lookup keys, ordered per hash value. More... | |
List< List< T > > | objects_ |
For each key the corresponding object. More... | |
label | nElmts_ |
The current number of elements in table. More... | |
iterator | endIter_ |
Iterator returned by end() More... | |
const_iterator | endConstIter_ |
const_iterator returned by end() 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 > &) |
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.
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.
StaticHashTable | ( | Istream & | , |
const label | size = 128 |
||
) |
Construct from Istream.
StaticHashTable | ( | const StaticHashTable< T, Key, Hash > & | ) |
Construct as copy.
StaticHashTable | ( | const Xfer< StaticHashTable< T, Key, Hash > > & | ) |
Construct by transferring the parameter contents.
~StaticHashTable | ( | ) |
Destructor.
Definition at line 118 of file StaticHashTable.C.
|
staticprivate |
Return a canonical (power-of-two) size.
|
inlineprivate |
Return the hash index of the Key within the current table size.
No checks for zero-sized tables.
Definition at line 35 of file StaticHashTableI.H.
|
private |
Assign a new hashed entry to a possibly already existing key.
|
inline |
Return number of elements in table.
Definition at line 45 of file StaticHashTableI.H.
|
inline |
Return true if the hash table is empty.
Definition at line 52 of file StaticHashTableI.H.
bool found | ( | const Key & | key | ) | const |
Return true if hashed entry is found in table.
Definition at line 125 of file StaticHashTable.C.
Referenced by main().
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 156 of file StaticHashTable.C.
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 189 of file StaticHashTable.C.
Foam::List< Key > toc | ( | ) | const |
Return the table of contents.
Definition at line 221 of file StaticHashTable.C.
Foam::Ostream & printInfo | ( | Ostream & | os | ) | const |
Print information.
Definition at line 61 of file StaticHashTableIO.C.
Referenced by main().
|
inline |
Insert a new hashed entry.
Definition at line 60 of file StaticHashTableI.H.
Referenced by main(), and StaticHashTable< T, Key, Hash >::resize().
|
inline |
Assign a new hashed entry, overwriting existing entries.
bool erase | ( | const iterator & | it | ) |
Erase an hashed entry specified by given iterator.
bool erase | ( | const Key & | key | ) |
Erase an hashed entry specified by given key if in table.
Definition at line 351 of file StaticHashTable.C.
void resize | ( | const label | newSize | ) |
Resize the hash table for efficiency.
Definition at line 389 of file StaticHashTable.C.
label erase | ( | const StaticHashTable< T, Key, Hash > & | ) |
Remove entries in the given hash table from this hash table.
Return the number of elements removed
void clear | ( | ) |
Clear all entries from table.
Definition at line 430 of file StaticHashTable.C.
void clearStorage | ( | ) |
Clear the table entries and the table itself.
Equivalent to clear() followed by resize(1)
Definition at line 443 of file StaticHashTable.C.
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 452 of file StaticHashTable.C.
|
inline |
Transfer contents to the Xfer container.
Definition at line 82 of file StaticHashTableI.H.
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 479 of file StaticHashTable.C.
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 517 of file StaticHashTable.C.
bool operator!= | ( | const StaticHashTable< T, Key, Hash > & | rhs | ) | const |
The opposite of the equality operation.
Definition at line 539 of file StaticHashTable.C.
|
inline |
Iterator set to the beginning of the StaticHashTable.
Definition at line 337 of file StaticHashTableI.H.
|
inline |
Iterator set to beyond the end of the StaticHashTable.
Definition at line 361 of file StaticHashTableI.H.
|
inline |
const_iterator set to the beginning of the StaticHashTable
Definition at line 369 of file StaticHashTableI.H.
Referenced by StaticHashTable< T, Key, Hash >::operator=(), and StaticHashTable< T, Key, Hash >::operator==().
|
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 >::operator=(), and StaticHashTable< T, Key, Hash >::operator==().
|
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 |
const typedef 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 lookup keys, ordered per hash value.
Definition at line 113 of file StaticHashTable.H.
Referenced by StaticHashTable::Iterator< T &, StaticHashTable< T, Key, Hash > & >::key(), StaticHashTable< T, Key, Hash >::operator=(), and StaticHashTable< T, Key, Hash >::transfer().
For each key the corresponding object.
Definition at line 116 of file StaticHashTable.H.
Referenced by StaticHashTable< T, Key, Hash >::transfer().
|
private |
The current number of elements in table.
Definition at line 119 of file StaticHashTable.H.
Referenced by StaticHashTable< T, Key, Hash >::transfer().
|
private |
Definition at line 386 of file StaticHashTable.H.
Referenced by StaticHashTable< T, Key, Hash >::transfer().
|
private |
const_iterator returned by end()
Definition at line 389 of file StaticHashTable.H.
Referenced by StaticHashTable< T, Key, Hash >::transfer().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.