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 = nullptr |
| 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 53 of file HashTableMap.h.
| typedef HashTableMapEnumeratorT<KeyType, ValueType> Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::Enumerator |
Definition at line 63 of file HashTableMap.h.
| typedef KeyTraitsType::HashValueType Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::HashValueType |
Definition at line 61 of file HashTableMap.h.
| typedef KeyTraitsType::KeyTypeConstRef Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::KeyTypeConstRef |
Definition at line 58 of file HashTableMap.h.
| typedef KeyTraitsType::KeyTypeValue Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::KeyTypeValue |
Definition at line 59 of file HashTableMap.h.
| typedef KeyTraitsType::Printable Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::Printable |
Definition at line 60 of file HashTableMap.h.
| typedef HashTableMapT<KeyType, ValueType, KeyTraitsType> Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::ThatClass |
Definition at line 62 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 109 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 127 of file HashTableMap.h.
|
inline |
Definition at line 139 of file HashTableMap.h.
|
inlineprivate |
Definition at line 451 of file HashTableMap.h.
|
inlineprivate |
Definition at line 465 of file HashTableMap.h.
|
inlineprivate |
Definition at line 526 of file HashTableMap.h.
|
inlineprivate |
Definition at line 516 of file HashTableMap.h.
|
inlineprivate |
Definition at line 481 of file HashTableMap.h.
|
inlineprivate |
Definition at line 521 of file HashTableMap.h.
|
inlineprivate |
Definition at line 494 of file HashTableMap.h.
|
inlineprivate |
Definition at line 555 of file HashTableMap.h.
|
inlineprivate |
Definition at line 606 of file HashTableMap.h.
|
inlineprivate |
Definition at line 476 of file HashTableMap.h.
|
inlineprivate |
Definition at line 471 of file HashTableMap.h.
|
inlineprivate |
Definition at line 535 of file HashTableMap.h.
|
inlineprivate |
Definition at line 540 of file HashTableMap.h.
|
inlineprivate |
Definition at line 545 of file HashTableMap.h.
|
inlineprivate |
Definition at line 581 of file HashTableMap.h.
|
inlineprivate |
Definition at line 585 of file HashTableMap.h.
|
inlineprivate |
Rehashes the data after changing key values.
Definition at line 413 of file HashTableMap.h.
Referenced by Arcane::HashTableMapT< VariableNameInfo, IVariable *, VNIComparer >::rehash(), and Arcane::HashTableMapT< VariableNameInfo, IVariable *, VNIComparer >::resize().
|
inlineprivate |
Definition at line 550 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 263 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 599 of file HashTableMap.h.
|
inlineprivate |
Definition at line 594 of file HashTableMap.h.
|
inline |
Definition at line 350 of file HashTableMap.h.
|
inline |
Definition at line 355 of file HashTableMap.h.
|
inline |
Deletes all elements from the table.
Definition at line 181 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 385 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 400 of file HashTableMap.h.
Referenced by Arcane::mesh::Parallel3EdgeUniqueIdBuilder::compute().
|
inline |
true if a value with key id is present
Definition at line 170 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 192 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 202 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 323 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 297 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 212 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 236 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 343 of file HashTableMap.h.
Referenced by Arcane::mesh::ItemFamilyVariableSerializer::_serializePartialVariable(), and Arcane::XmfMeshReader::readMeshFromFile().
|
inline |
Copy assignment operator.
Definition at line 145 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 226 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 250 of file HashTableMap.h.
|
inline |
Rehashes the data after changing key values.
Definition at line 376 of file HashTableMap.h.
|
inline |
Removes the value associated with key id.
Definition at line 279 of file HashTableMap.h.
|
inline |
Resizes the hash table.
Definition at line 361 of file HashTableMap.h.
|
private |
Definition at line 615 of file HashTableMap.h.
|
private |
Value allocation buffer.
Definition at line 441 of file HashTableMap.h.
|
private |
Pointer to the first usable Data.
Definition at line 442 of file HashTableMap.h.
|
private |
Maximum number of elements before resizing.
Definition at line 614 of file HashTableMap.h.
|
mutable |
Definition at line 446 of file HashTableMap.h.
|
mutable |
Definition at line 447 of file HashTableMap.h.