Hash table for associative arrays. More...
#include <arcane/utils/HashTableMap.h>
Classes | |
| struct | Data |
Public Types | |
| typedef KeyTraitsType::KeyTypeConstRef | KeyTypeConstRef |
| typedef KeyTraitsType::KeyTypeValue | KeyTypeValue |
| typedef KeyTraitsType::Printable | Printable |
| typedef KeyTraitsType::HashValueType | HashValueType |
| typedef HashTableMapT< KeyType, ValueType, KeyTraitsType > | ThatClass |
| typedef HashTableMapEnumeratorT< KeyType, ValueType > | Enumerator |
Public Member Functions | |
| HashTableMapT (Integer table_size, bool use_prime) | |
| Creates a table of size table_size. | |
| HashTableMapT (Integer table_size, bool use_prime, Integer buffer_size) | |
| Creates a table of size table_size. | |
| ThatClass & | operator= (const ThatClass &from) |
| Copy assignment operator. | |
| bool | hasKey (KeyTypeConstRef id) |
| true if a value with key id is present | |
| void | clear () |
| Deletes all elements from the table. | |
| Data * | lookup (KeyTypeConstRef id) |
| Searches for the value corresponding to key id. | |
| const Data * | lookup (KeyTypeConstRef id) const |
| Searches for the value corresponding to key id. | |
| ValueType & | lookupValue (KeyTypeConstRef id) |
| Searches for the value corresponding to key id. | |
| ValueType & | operator[] (KeyTypeConstRef id) |
| Searches for the value corresponding to key id. | |
| const ValueType & | lookupValue (KeyTypeConstRef id) const |
| Searches for the value corresponding to key id. | |
| const ValueType & | operator[] (KeyTypeConstRef id) const |
| Searches for the value corresponding to key id. | |
| bool | add (KeyTypeConstRef id, const ValueType &value) |
| Adds the value value corresponding to key id. | |
| void | remove (KeyTypeConstRef id) |
| Removes the value associated with key id. | |
| Data * | lookupAdd (KeyTypeConstRef id, const ValueType &value, bool &is_add) |
| Searches for or adds the value corresponding to key id. | |
| Data * | lookupAdd (KeyTypeConstRef id) |
| Searches for or adds the value corresponding to key id. | |
| void | nocheckAdd (KeyTypeConstRef id, const ValueType &value) |
| Adds the value value corresponding to the key id. | |
| ArrayView< Data * > | buckets () |
| ConstArrayView< Data * > | buckets () const |
| void | resize (Integer new_size, bool use_prime=false) |
| Resizes the hash table. | |
| void | rehash () |
| Rehashes the data after changing key values. | |
| template<class Lambda> | |
| void | each (const Lambda &lambda) |
| Applies the functor f to all elements of the collection. | |
| template<class Lambda> | |
| void | eachValue (const Lambda &lambda) |
| Applies the functor f to all elements of the collection and uses x->value() (of type ValueType) as an argument. | |
| Public Member Functions inherited from Arcane::HashTableBase | |
| HashTableBase (Integer table_size, bool use_prime) | |
| Creates a table of size table_size. | |
| Integer | nearestPrimeNumber (Integer n) |
| Returns the nearest prime number greater than n. The nearest prime number greater than n is returned using a pre-determined prime number table. | |
| Integer | count () const |
| Number of elements in the table. | |
Public Attributes | |
| Int64 | m_nb_collision = 0 |
| Int64 | m_nb_direct = 0 |
Private Member Functions | |
| void | _rehash (Integer new_size) |
| Rehashes the data after changing key values. | |
| Data * | _add (Integer bucket, KeyTypeConstRef key, const ValueType &value) |
| HashValueType | _applyHash (KeyTypeConstRef id) const |
| Integer | _keyToBucket (KeyTypeConstRef id) const |
| Integer | _hashValueToBucket (KeyTypeValue id) const |
| Data * | _baseLookupBucket (Integer bucket, KeyTypeConstRef id) const |
| Data * | _baseRemoveBucket (Integer bucket, KeyTypeConstRef id) |
| Data * | _baseLookup (KeyTypeConstRef id) const |
| Data * | _baseRemove (KeyTypeConstRef id) |
| void | _baseAdd (Integer bucket, KeyTypeConstRef id, Data *hd) |
| Data * | _lookup (KeyTypeConstRef id) |
| const Data * | _lookup (KeyTypeConstRef id) const |
| Data * | _lookupBucket (Integer bucket, KeyTypeConstRef id) const |
| Data * | _removeBucket (Integer bucket, KeyTypeConstRef id) |
| void | _checkResize () |
| void | _print (FalseType) |
| void | _print (TrueType) |
| void _throwNotFound | ARCANE_NORETURN (KeyTypeConstRef, FalseType) const |
| void _throwNotFound | ARCANE_NORETURN (KeyTypeConstRef id, TrueType) const |
| void | _computeMaxCount () |
Private Attributes | |
| MultiBufferT< Data > * | m_buffer |
| Value allocation buffer. | |
| Data * | m_first_free = nullptr |
| Pointer to the first usable Data. | |
| Integer | m_max_count = 0 |
| Maximum number of elements before resizing. | |
| UniqueArray< Data * > | m_buckets |
Additional Inherited Members | |
| Protected Member Functions inherited from Arcane::HashTableBase | |
| void _throwNotFound | ARCANE_NORETURN () const |
| Protected Attributes inherited from Arcane::HashTableBase | |
| Integer | m_count |
| Number of elements. | |
| Integer | m_nb_bucket |
| Number of buckets. | |
Hash table for associative arrays.
This table allows storing a value based on a key. The key is of type KeyType and the value is ValueType.
For now, this table only allows adding values. The memory associated with each entry in the array is managed by a MultiBufferT.
It is possible to specify a hash function different from the default function by specifying the third template parameter KeyTraitsType.
For performance reasons, it is preferable that the size of the table (buckets) is a prime number.
Definition at line 50 of file HashTableMap.h.
| typedef HashTableMapEnumeratorT<KeyType, ValueType> Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::Enumerator |
Definition at line 60 of file HashTableMap.h.
| typedef KeyTraitsType::HashValueType Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::HashValueType |
Definition at line 58 of file HashTableMap.h.
| typedef KeyTraitsType::KeyTypeConstRef Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::KeyTypeConstRef |
Definition at line 55 of file HashTableMap.h.
| typedef KeyTraitsType::KeyTypeValue Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::KeyTypeValue |
Definition at line 56 of file HashTableMap.h.
| typedef KeyTraitsType::Printable Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::Printable |
Definition at line 57 of file HashTableMap.h.
| typedef HashTableMapT<KeyType, ValueType, KeyTraitsType> Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::ThatClass |
Definition at line 59 of file HashTableMap.h.
|
inline |
Creates a table of size table_size.
If use_prime is true, it uses the nearestPrimeNumber() function to have a size that is a prime number.
Definition at line 106 of file HashTableMap.h.
|
inline |
Creates a table of size table_size.
If use_prime is true, it uses the nearestPrimeNumber() function to have a size that is a prime number.
Definition at line 124 of file HashTableMap.h.
|
inline |
Definition at line 136 of file HashTableMap.h.
|
inlineprivate |
Definition at line 448 of file HashTableMap.h.
|
inlineprivate |
Definition at line 462 of file HashTableMap.h.
|
inlineprivate |
Definition at line 523 of file HashTableMap.h.
|
inlineprivate |
Definition at line 513 of file HashTableMap.h.
|
inlineprivate |
Definition at line 478 of file HashTableMap.h.
|
inlineprivate |
Definition at line 518 of file HashTableMap.h.
|
inlineprivate |
Definition at line 491 of file HashTableMap.h.
|
inlineprivate |
Definition at line 552 of file HashTableMap.h.
|
inlineprivate |
Definition at line 603 of file HashTableMap.h.
|
inlineprivate |
Definition at line 473 of file HashTableMap.h.
|
inlineprivate |
Definition at line 468 of file HashTableMap.h.
|
inlineprivate |
Definition at line 532 of file HashTableMap.h.
|
inlineprivate |
Definition at line 537 of file HashTableMap.h.
|
inlineprivate |
Definition at line 542 of file HashTableMap.h.
|
inlineprivate |
Definition at line 578 of file HashTableMap.h.
|
inlineprivate |
Definition at line 582 of file HashTableMap.h.
|
inlineprivate |
Rehashes the data after changing key values.
Definition at line 410 of file HashTableMap.h.
Referenced by Arcane::HashTableMapT< VariableNameInfo, IVariable *, VNIComparer >::rehash(), and Arcane::HashTableMapT< VariableNameInfo, IVariable *, VNIComparer >::resize().
|
inlineprivate |
Definition at line 547 of file HashTableMap.h.
|
inline |
Adds the value value corresponding to key id.
If a value corresponding to id already exists, it is replaced.
| true | if the key is added |
| false | if the key already exists and is replaced |
Definition at line 260 of file HashTableMap.h.
Referenced by Arcane::mesh::FaceUniqueIdBuilder::_computeFacesUniqueIdsParallelV1(), Arcane::mesh::TiedInterfaceBuilder::_gatherFaces(), Arcane::LimaMalippReaderT< ReaderWrapper >::_readMeshPart(), Arcane::mesh::ItemFamily::checkUniqueIds(), and Arcane::mesh::Parallel3EdgeUniqueIdBuilder::compute().
|
inlineprivate |
Definition at line 596 of file HashTableMap.h.
|
inlineprivate |
Definition at line 591 of file HashTableMap.h.
|
inline |
Definition at line 347 of file HashTableMap.h.
|
inline |
Definition at line 352 of file HashTableMap.h.
|
inline |
Deletes all elements from the table.
Definition at line 178 of file HashTableMap.h.
Referenced by Arcane::HashTableMapT< VariableNameInfo, IVariable *, VNIComparer >::resize().
|
inline |
Applies the functor f to all elements of the collection.
Definition at line 382 of file HashTableMap.h.
|
inline |
Applies the functor f to all elements of the collection and uses x->value() (of type ValueType) as an argument.
Definition at line 397 of file HashTableMap.h.
Referenced by Arcane::mesh::Parallel3EdgeUniqueIdBuilder::compute().
|
inline |
true if a value with key id is present
Definition at line 167 of file HashTableMap.h.
Referenced by Arcane::mesh::FaceUniqueIdBuilder::_computeFacesUniqueIdsParallelV1(), Arcane::mesh::ParallelAMRConsistency::_gatherFaces(), Arcane::mesh::TiedInterfaceBuilder::_gatherFaces(), and Arcane::mesh::ParallelAMRConsistency::_gatherItems().
|
inline |
Searches for the value corresponding to key id.
Definition at line 189 of file HashTableMap.h.
Referenced by Arcane::mesh::ItemFamilyVariableSerializer::_serializePartialVariable(), and Arcane::mesh::ItemFamily::checkUniqueIds().
|
inline |
Searches for the value corresponding to key id.
Definition at line 199 of file HashTableMap.h.
|
inline |
Searches for or adds the value corresponding to key id.
If key id is already in the table, returns a reference to this value and sets is_add to false. Otherwise, adds key id with value ValueType() (which must exist).
The returned structure is never null and can be kept because it does not change address as long as this hash table instance exists
Definition at line 320 of file HashTableMap.h.
|
inline |
Searches for or adds the value corresponding to key id.
If key id is already in the table, returns a reference to this value and sets is_add to false. Otherwise, adds key id with value value and sets is_add to true.
The returned structure is never null and can be kept because it does not change address as long as this hash table instance exists
Definition at line 294 of file HashTableMap.h.
Referenced by Arcane::mesh::FaceUniqueIdBuilder::_computeFacesUniqueIdsParallelV2(), and Arcane::mesh::GhostLayerBuilder::addGhostChildFromParent().
|
inline |
Searches for the value corresponding to key id.
An exception is generated if the value is not found.
Definition at line 209 of file HashTableMap.h.
Referenced by Arcane::LimaMalippReaderT< ReaderWrapper >::_readMeshPart(), Arcane::HashTableMapT< VariableNameInfo, IVariable *, VNIComparer >::operator[](), and Arcane::HashTableMapT< VariableNameInfo, IVariable *, VNIComparer >::operator[]().
|
inline |
Searches for the value corresponding to key id.
An exception is generated if the value is not found.
Definition at line 233 of file HashTableMap.h.
|
inline |
Adds the value value corresponding to the key id.
If a value corresponding to id already exists, the result is undefined.
Definition at line 340 of file HashTableMap.h.
Referenced by Arcane::mesh::ItemFamilyVariableSerializer::_serializePartialVariable(), and Arcane::XmfMeshReader::readMeshFromFile().
|
inline |
Copy assignment operator.
Definition at line 142 of file HashTableMap.h.
|
inline |
Searches for the value corresponding to key id.
An exception is generated if the value is not found.
Definition at line 223 of file HashTableMap.h.
|
inline |
Searches for the value corresponding to key id.
An exception is generated if the value is not found.
Definition at line 247 of file HashTableMap.h.
|
inline |
Rehashes the data after changing key values.
Definition at line 373 of file HashTableMap.h.
|
inline |
Removes the value associated with key id.
Definition at line 276 of file HashTableMap.h.
|
inline |
Resizes the hash table.
Definition at line 358 of file HashTableMap.h.
|
private |
Definition at line 612 of file HashTableMap.h.
|
private |
Value allocation buffer.
Definition at line 438 of file HashTableMap.h.
|
private |
Pointer to the first usable Data.
Definition at line 439 of file HashTableMap.h.
|
private |
Maximum number of elements before resizing.
Definition at line 611 of file HashTableMap.h.
|
mutable |
Definition at line 443 of file HashTableMap.h.
|
mutable |
Definition at line 444 of file HashTableMap.h.