Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType > Class Template Reference

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, ValueTypeEnumerator

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.
Datalookup (KeyTypeConstRef id)
 Searches for the value corresponding to key id.
const Datalookup (KeyTypeConstRef id) const
 Searches for the value corresponding to key id.
ValueTypelookupValue (KeyTypeConstRef id)
 Searches for the value corresponding to key id.
ValueTypeoperator[] (KeyTypeConstRef id)
 Searches for the value corresponding to key id.
const ValueTypelookupValue (KeyTypeConstRef id) const
 Searches for the value corresponding to key id.
const ValueTypeoperator[] (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.
DatalookupAdd (KeyTypeConstRef id, const ValueType &value, bool &is_add)
 Searches for or adds the value corresponding to key id.
DatalookupAdd (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

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.

Detailed Description

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
class Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >

Definition at line 50 of file HashTableMap.h.

Member Typedef Documentation

◆ Enumerator

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
typedef HashTableMapEnumeratorT<KeyType, ValueType> Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::Enumerator

Definition at line 60 of file HashTableMap.h.

◆ HashValueType

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
typedef KeyTraitsType::HashValueType Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::HashValueType

Definition at line 58 of file HashTableMap.h.

◆ KeyTypeConstRef

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
typedef KeyTraitsType::KeyTypeConstRef Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::KeyTypeConstRef

Definition at line 55 of file HashTableMap.h.

◆ KeyTypeValue

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
typedef KeyTraitsType::KeyTypeValue Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::KeyTypeValue

Definition at line 56 of file HashTableMap.h.

◆ Printable

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
typedef KeyTraitsType::Printable Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::Printable

Definition at line 57 of file HashTableMap.h.

◆ ThatClass

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
typedef HashTableMapT<KeyType, ValueType, KeyTraitsType> Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::ThatClass

Definition at line 59 of file HashTableMap.h.

Constructor & Destructor Documentation

◆ HashTableMapT() [1/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::HashTableMapT ( Integer table_size,
bool use_prime )
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.

◆ HashTableMapT() [2/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::HashTableMapT ( Integer table_size,
bool use_prime,
Integer buffer_size )
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.

◆ ~HashTableMapT()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::~HashTableMapT ( )
inline

Definition at line 136 of file HashTableMap.h.

Member Function Documentation

◆ add()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
bool Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::add ( KeyTypeConstRef id,
const ValueType & value )
inline

Adds the value value corresponding to key id.

If a value corresponding to id already exists, it is replaced.

Return values
trueif the key is added
falseif the key already exists and is replaced

Definition at line 260 of file HashTableMap.h.

◆ buckets() [1/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
ArrayView< Data * > Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::buckets ( )
inline

Definition at line 347 of file HashTableMap.h.

◆ buckets() [2/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
ConstArrayView< Data * > Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::buckets ( ) const
inline

Definition at line 352 of file HashTableMap.h.

◆ clear()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
void Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::clear ( )
inline

Deletes all elements from the table.

Definition at line 178 of file HashTableMap.h.

Referenced by resize().

◆ each()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
template<class Lambda>
void Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::each ( const Lambda & lambda)
inline

Applies the functor f to all elements of the collection.

Definition at line 382 of file HashTableMap.h.

◆ eachValue()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
template<class Lambda>
void Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::eachValue ( const Lambda & lambda)
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.

◆ hasKey()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
bool Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::hasKey ( KeyTypeConstRef id)
inline

true if a value with key id is present

Definition at line 167 of file HashTableMap.h.

◆ lookup() [1/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
Data * Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::lookup ( KeyTypeConstRef id)
inline

Searches for the value corresponding to key id.

Returns
the structure associated with key id (0 if none)

Definition at line 189 of file HashTableMap.h.

◆ lookup() [2/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
const Data * Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::lookup ( KeyTypeConstRef id) const
inline

Searches for the value corresponding to key id.

Returns
the structure associated with key id (0 if none)

Definition at line 199 of file HashTableMap.h.

◆ lookupAdd() [1/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
Data * Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::lookupAdd ( KeyTypeConstRef id)
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.

◆ lookupAdd() [2/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
Data * Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::lookupAdd ( KeyTypeConstRef id,
const ValueType & value,
bool & is_add )
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.

◆ lookupValue() [1/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
ValueType & Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::lookupValue ( KeyTypeConstRef id)
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 operator[](), and operator[]().

◆ lookupValue() [2/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
const ValueType & Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::lookupValue ( KeyTypeConstRef id) const
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.

◆ nocheckAdd()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
void Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::nocheckAdd ( KeyTypeConstRef id,
const ValueType & value )
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.

◆ operator=()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
ThatClass & Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::operator= ( const ThatClass & from)
inline

Copy assignment operator.

Definition at line 142 of file HashTableMap.h.

◆ operator[]() [1/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
ValueType & Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::operator[] ( KeyTypeConstRef id)
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.

◆ operator[]() [2/2]

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
const ValueType & Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::operator[] ( KeyTypeConstRef id) const
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.

◆ rehash()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
void Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::rehash ( )
inline

Rehashes the data after changing key values.

Definition at line 373 of file HashTableMap.h.

◆ remove()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
void Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::remove ( KeyTypeConstRef id)
inline

Removes the value associated with key id.

Definition at line 276 of file HashTableMap.h.

◆ resize()

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
void Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::resize ( Integer new_size,
bool use_prime = false )
inline

Resizes the hash table.

Definition at line 358 of file HashTableMap.h.

Member Data Documentation

◆ m_nb_collision

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
Int64 Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::m_nb_collision = 0
mutable

Definition at line 443 of file HashTableMap.h.

◆ m_nb_direct

template<typename KeyType, typename ValueType, typename KeyTraitsType = HashTraitsT<KeyType>>
Int64 Arcane::HashTableMapT< KeyType, ValueType, KeyTraitsType >::m_nb_direct = 0
mutable

Definition at line 444 of file HashTableMap.h.


The documentation for this class was generated from the following file: