Go to the documentation of this file.
42 #ifndef StaticHashTable_H
43 #define StaticHashTable_H
58 template<
class T>
class List;
61 template<
class T,
class Key,
class Hash>
Istream&
operator>>
67 template<
class T,
class Key,
class Hash>
Ostream&
operator<<
106 template<
class T,
class Key=word,
class Hash=
string::hash>
107 class StaticHashTable
109 public StaticHashTableCore
130 bool set(
const Key&,
const T& newElmt,
bool protect);
138 template<
class TRef,
class TableRef>
156 friend class Iterator
162 friend class Iterator
196 inline bool empty()
const;
199 bool found(
const Key& key)
const;
219 bool insert(
const Key& key,
const T& newElmt);
222 inline bool set(
const Key&,
const T& newElmt);
228 bool erase(
const Key& key);
295 template<
class TRef,
class TableRef>
300 template<
class TRef2,
class TableRef2>
347 inline const Key&
key()
const;
377 friend Ostream& operator<< <T, Key, Hash>
404 #ifndef NoStaticHashTableC
label size_type
The type that can represent the size of a StaticHashTable.
iterator endIter_
Iterator returned by end()
bool operator==(const iterator &) const
bool operator==(const StaticHashTable< T, Key, Hash > &) const
Equality. Two hash tables are equal if all contents of first are.
T & reference
Type that can be used for storing into StaticHashTable::value_type.
label nElmts_
The current number of elements in table.
~StaticHashTable()
Destructor.
void operator=(const StaticHashTable< T, Key, Hash > &)
Assignment.
ClassName("StaticHashTable")
Define template name and debug.
label elemIndex_
Index of current element at hashIndex.
dimensionedScalar TRef("TRef", dimTemperature, laminarTransport)
List< List< Key > > keys_
The lookup keys, ordered per hash value.
TableRef hashTable_
Reference to the StaticHashTable this is an iterator for.
const typedef T & const_reference
Type that can be used for storing into constant.
A simple container for copying or transferring objects of type <T>.
void clear()
Clear all entries from table.
void clearStorage()
Clear the table entries and the table itself.
STL conforming hash table.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & printInfo(Ostream &) const
Print information.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const_iterator cbegin() const
const_iterator set to the beginning of the StaticHashTable
Macro definitions for declaring ClassName(), NamespaceName(), etc.
bool empty() const
Return true if the hash table is empty.
Xfer< StaticHashTable< T, Key, Hash > > xfer()
Transfer contents to the Xfer container.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool set(const Key &, const T &newElmt, bool protect)
Assign a new hashed entry to a possibly already existing key.
Iterator< T &, StaticHashTable< T, Key, Hash > & > iterator
T & operator()(const Key &)
Find and return an hashed entry, create it null if not present.
StaticHashTableCore()
Construct null.
iteratorEnd()
Construct null.
bool operator!=(const iterator &) const
const_iterator endConstIter_
const_iterator returned by end()
bool erase(const iterator &it)
Erase an hashed entry specified by given iterator.
List< Key > toc() const
Return the table of contents.
label size() const
Return number of elements in table.
A zero-sized end iterator.
void resize(const label newSize)
Resize the hash table for efficiency.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
Template-invariant bits for StaticHashTable.
static label canonicalSize(const label)
Return a canonical (power-of-two) size.
const iterator & end()
Iterator set to beyond the end of the StaticHashTable.
label hashIndex_
Current hash index.
Iterator< const T &, const StaticHashTable< T, Key, Hash > & > const_iterator
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool insert(const Key &key, const T &newElmt)
Insert a new hashed entry.
void operator=(const iterator &)
T value_type
Type of values the StaticHashTable contains.
iterator begin()
Iterator set to the beginning of the StaticHashTable.
bool operator!=(const StaticHashTable< T, Key, Hash > &) const
The opposite of the equality operation.
StaticHashTable(const label size=128)
Construct given initial table size.
label hashKeyIndex(const Key &) const
Return the hash index of the Key within the current table size.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
T & operator[](const Key &)
Find and return an hashed entry.
bool found(const Key &key) const
Return true if hashed entry is found in table.
const const_iterator & cend() const
const_iterator set to beyond the end of the StaticHashTable
List< List< T > > objects_
For each key the corresponding object.
void transfer(StaticHashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
static label canonicalSize(const label)
Return a canonical (power-of-two) size.