Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::HashTableBaseT< KeyType, TraitsType > Class Template Reference

Base class for a hash table for associative arrays. More...

#include <arcane/utils/HashTable.h>

Inheritance diagram for Arcane::HashTableBaseT< KeyType, TraitsType >:
Collaboration diagram for Arcane::HashTableBaseT< KeyType, TraitsType >:

Classes

struct  HashData

Public Types

typedef TraitsType::KeyTypeConstRef KeyTypeConstRef
typedef TraitsType::KeyTypeValue KeyTypeValue

Public Member Functions

 HashTableBaseT (Integer table_size, bool use_prime)
 Creates a table of size table_size.
bool hasKey (KeyTypeConstRef id) const
 true if a value with the key id is present
void clear ()
 Clears all elements from the table.
void resize (Integer new_table_size, bool use_prime=false)
 Resizes the hash table.
void rehash ()
 Repositions data after key value change.
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.

Protected Member Functions

Integer _hash (KeyTypeConstRef id) const
HashData_baseLookupBucket (Integer bucket, KeyTypeConstRef id) const
HashData_baseRemoveBucket (Integer bucket, KeyTypeConstRef id)
HashData_baseLookup (KeyTypeConstRef id) const
HashData_baseRemove (KeyTypeConstRef id)
void _baseAdd (Integer bucket, KeyTypeConstRef id, HashData *hd)
Protected Member Functions inherited from Arcane::HashTableBase
void _throwNotFound ARCANE_NORETURN () const

Protected Attributes

UniqueArray< HashData * > m_buckets
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 TraitsType>
class Arcane::HashTableBaseT< KeyType, TraitsType >

Base class for a hash table for associative arrays.

This table allows storing a value based on a key. The value type is managed by the derived class HashTableMapT.

The hash table is managed as an array whose number of elements is given by the table size (m_nb_bucket). The elements are then stored in a linked list.

This table only allows adding values.

For performance reasons, it is preferable that the table size (buckets) is a prime number.

Definition at line 99 of file HashTable.h.

Member Typedef Documentation

◆ KeyTypeConstRef

template<typename KeyType, typename TraitsType>
typedef TraitsType::KeyTypeConstRef Arcane::HashTableBaseT< KeyType, TraitsType >::KeyTypeConstRef

Definition at line 104 of file HashTable.h.

◆ KeyTypeValue

template<typename KeyType, typename TraitsType>
typedef TraitsType::KeyTypeValue Arcane::HashTableBaseT< KeyType, TraitsType >::KeyTypeValue

Definition at line 105 of file HashTable.h.

Constructor & Destructor Documentation

◆ HashTableBaseT()

template<typename KeyType, typename TraitsType>
Arcane::HashTableBaseT< KeyType, TraitsType >::HashTableBaseT ( Integer table_size,
bool use_prime )
inline

Creates a table of size table_size.

If use_prime is true, uses the nearestPrimeNumber() function to have a size that is a prime number.

Definition at line 148 of file HashTable.h.

References Arcane::HashTableBase::HashTableBase(), and Arcane::HashTableBase::m_nb_bucket.

Here is the call graph for this function:

Member Function Documentation

◆ _baseAdd()

template<typename KeyType, typename TraitsType>
void Arcane::HashTableBaseT< KeyType, TraitsType >::_baseAdd ( Integer bucket,
KeyTypeConstRef id,
HashData * hd )
inlineprotected

Definition at line 254 of file HashTable.h.

◆ _baseLookup()

template<typename KeyType, typename TraitsType>
HashData * Arcane::HashTableBaseT< KeyType, TraitsType >::_baseLookup ( KeyTypeConstRef id) const
inlineprotected

Definition at line 246 of file HashTable.h.

◆ _baseLookupBucket()

template<typename KeyType, typename TraitsType>
HashData * Arcane::HashTableBaseT< KeyType, TraitsType >::_baseLookupBucket ( Integer bucket,
KeyTypeConstRef id ) const
inlineprotected

Definition at line 218 of file HashTable.h.

◆ _baseRemove()

template<typename KeyType, typename TraitsType>
HashData * Arcane::HashTableBaseT< KeyType, TraitsType >::_baseRemove ( KeyTypeConstRef id)
inlineprotected

Definition at line 250 of file HashTable.h.

◆ _baseRemoveBucket()

template<typename KeyType, typename TraitsType>
HashData * Arcane::HashTableBaseT< KeyType, TraitsType >::_baseRemoveBucket ( Integer bucket,
KeyTypeConstRef id )
inlineprotected

Definition at line 226 of file HashTable.h.

◆ _hash()

template<typename KeyType, typename TraitsType>
Integer Arcane::HashTableBaseT< KeyType, TraitsType >::_hash ( KeyTypeConstRef id) const
inlineprotected

Definition at line 214 of file HashTable.h.

◆ clear()

template<typename KeyType, typename TraitsType>
void Arcane::HashTableBaseT< KeyType, TraitsType >::clear ( )
inline

Clears all elements from the table.

Definition at line 169 of file HashTable.h.

References Arcane::HashTableBase::m_count.

Referenced by resize().

Here is the caller graph for this function:

◆ hasKey()

template<typename KeyType, typename TraitsType>
bool Arcane::HashTableBaseT< KeyType, TraitsType >::hasKey ( KeyTypeConstRef id) const
inline

true if a value with the key id is present

Definition at line 158 of file HashTable.h.

◆ rehash()

template<typename KeyType, typename TraitsType>
void Arcane::HashTableBaseT< KeyType, TraitsType >::rehash ( )
inline

Repositions data after key value change.

Definition at line 197 of file HashTable.h.

References Arcane::HashTableBaseT< KeyType, TraitsType >::HashData::m_key, and Arcane::AbstractArray< T >::size().

Here is the call graph for this function:

◆ resize()

template<typename KeyType, typename TraitsType>
void Arcane::HashTableBaseT< KeyType, TraitsType >::resize ( Integer new_table_size,
bool use_prime = false )
inline

Resizes the hash table.

Definition at line 176 of file HashTable.h.

References clear(), Arcane::HashTableBase::m_nb_bucket, Arcane::HashTableBase::nearestPrimeNumber(), and Arcane::AbstractArray< T >::size().

Here is the call graph for this function:

Member Data Documentation

◆ m_buckets

template<typename KeyType, typename TraitsType>
UniqueArray<HashData*> Arcane::HashTableBaseT< KeyType, TraitsType >::m_buckets
protected

Definition at line 265 of file HashTable.h.


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