![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
The class for generic Hash Tables. More...
#include <agrum/tools/core/hashTable.h>
Public Member Functions | |
template<typename... Args> | |
INLINE HashTable< Key, Val, Alloc >::value_type & | emplace (Args &&... args) |
template<typename Mount , typename OtherAlloc > | |
HashTable< Key, Mount, OtherAlloc > INLINE | map (Mount(*f)(Val), Size size, bool resize_pol, bool key_uniqueness_pol) const |
template<typename Mount , typename OtherAlloc > | |
HashTable< Key, Mount, OtherAlloc > INLINE | map (Mount(*f)(Val &), Size size, bool resize_pol, bool key_uniqueness_pol) const |
template<typename Mount , typename OtherAlloc > | |
HashTable< Key, Mount, OtherAlloc > INLINE | map (Mount(*f)(const Val &), Size size, bool resize_pol, bool key_uniqueness_pol) const |
template<typename Mount , typename OtherAlloc > | |
HashTable< Key, Mount, OtherAlloc > INLINE | map (const Mount &val, Size size, bool resize_pol, bool key_uniqueness_pol) const |
template<typename OtherAlloc > | |
INLINE bool | operator!= (const HashTable< Key, Val, OtherAlloc > &from) const |
Constructors / Destructors | |
HashTable (Size size_param=HashTableConst::default_size, bool resize_pol=HashTableConst::default_resize_policy, bool key_uniqueness_pol=HashTableConst::default_uniqueness_policy) | |
Default constructor. More... | |
HashTable (std::initializer_list< std::pair< Key, Val > > list) | |
Initializer list constructor. More... | |
HashTable (const HashTable< Key, Val, Alloc > &from) | |
Copy constructor. More... | |
template<typename OtherAlloc > | |
HashTable (const HashTable< Key, Val, OtherAlloc > &from) | |
Generalized copy constructor. More... | |
HashTable (HashTable< Key, Val, Alloc > &&from) | |
Move constructor. More... | |
~HashTable () | |
Class destructor. More... | |
Operators | |
HashTable< Key, Val, Alloc > & | operator= (const HashTable< Key, Val, Alloc > &from) |
Copy operator. More... | |
template<typename OtherAlloc > | |
HashTable< Key, Val, Alloc > & | operator= (const HashTable< Key, Val, OtherAlloc > &from) |
Generalized copy operator. More... | |
HashTable< Key, Val, Alloc > & | operator= (HashTable< Key, Val, Alloc > &&from) |
Move operator. More... | |
Val & | operator[] (const Key &key) |
Returns a reference on the value the key of which is passed in argument. More... | |
const Val & | operator[] (const Key &key) const |
returns a reference on the value the key of which is passed in argument More... | |
template<typename OtherAlloc > | |
bool | operator== (const HashTable< Key, Val, OtherAlloc > &from) const |
Checks whether two hashtables contain the same elements. More... | |
template<typename OtherAlloc > | |
bool | operator!= (const HashTable< Key, Val, OtherAlloc > &from) const |
Checks whether two hashtables contain different sets of elements. More... | |
Fine tuning | |
Size | capacity () const noexcept |
Returns the number of slots in the 'nodes' vector of the hashtable. More... | |
void | resize (Size new_size) |
Changes the number of slots in the 'nodes' vector of the hash table. More... | |
void | setResizePolicy (const bool new_policy) noexcept |
Enables the user to change dynamically the resizing policy. More... | |
bool | resizePolicy () const noexcept |
Returns the current resizing policy. More... | |
void | setKeyUniquenessPolicy (const bool new_policy) noexcept |
Enables the user to change dynamically the policy for checking whether there can exist several elements in the table with identical keys. More... | |
bool | keyUniquenessPolicy () const noexcept |
Returns the current checking policy. More... | |
Accessors / Modifiers | |
Size | size () const noexcept |
Returns the number of elements stored into the hashtable. More... | |
bool | exists (const Key &key) const |
Checks whether there exists an element with a given key in the hashtable. More... | |
value_type & | insert (const Key &key, const Val &val) |
Adds a new element (actually a copy of this element) into the hash table. More... | |
value_type & | insert (Key &&key, Val &&val) |
Moves a new element in the hash table. More... | |
value_type & | insert (const std::pair< Key, Val > &elt) |
Adds a new element (actually a copy of this element) into the hash table. More... | |
value_type & | insert (std::pair< Key, Val > &&elt) |
Moves a new element in the hash table. More... | |
template<typename... Args> | |
value_type & | emplace (Args &&... args) |
Emplace a new element into the hashTable. More... | |
mapped_type & | getWithDefault (const Key &key, const Val &default_value) |
Returns a reference on the element the key of which is passed in argument. More... | |
mapped_type & | getWithDefault (Key &&key, Val &&default_value) |
Returns a reference on the element the key of which is passed in argument. More... | |
void | set (const Key &key, const Val &default_value) |
Add a new property or modify it if it already existed. More... | |
void | reset (const Key &key) |
Removes a property (i.e., remove an element). More... | |
void | erase (const Key &key) |
Removes a given element from the hash table. More... | |
void | erase (const iterator_safe &iter) |
Removes a given element from the hash table. More... | |
void | erase (const const_iterator_safe &iter) |
Removes a given element from the hash table. More... | |
void | eraseByVal (const Val &val) |
Removes a given element from the hash table. More... | |
const Key & | keyByVal (const Val &val) const |
Returns a reference on the key given a value. More... | |
const Key & | key (const Key &key) const |
Returns a reference on a given key. More... | |
void | eraseAllVal (const Val &val) |
Removes all the elements having a certain value from the hash table. More... | |
void | clear () |
Removes all the elements in the hash table. More... | |
bool | empty () const noexcept |
Indicates whether the hash table is empty. More... | |
template<typename Mount , typename OtherAlloc = typename Alloc::template rebind< std::pair< Key, Mount > >::other> | |
HashTable< Key, Mount, OtherAlloc > | map (Mount(*f)(Val), Size size=Size(0), bool resize_pol=HashTableConst::default_resize_policy, bool key_uniqueness_pol=HashTableConst::default_uniqueness_policy) const |
Transforms a hashtable of vals into a hashtable of mountains. More... | |
template<typename Mount , typename OtherAlloc = typename Alloc::template rebind< std::pair< Key, Mount > >::other> | |
HashTable< Key, Mount, OtherAlloc > | map (Mount(*f)(Val &), Size size=Size(0), bool resize_pol=HashTableConst::default_resize_policy, bool key_uniqueness_pol=HashTableConst::default_uniqueness_policy) const |
Transforms a hashtable of vals into a hashtable of mountains. More... | |
template<typename Mount , typename OtherAlloc = typename Alloc::template rebind< std::pair< Key, Mount > >::other> | |
HashTable< Key, Mount, OtherAlloc > | map (Mount(*f)(const Val &), Size size=Size(0), bool resize_pol=HashTableConst::default_resize_policy, bool key_uniqueness_pol=HashTableConst::default_uniqueness_policy) const |
Transforms a hashtable of vals into a hashtable of mountains. More... | |
template<typename Mount , typename OtherAlloc = typename Alloc::template rebind< std::pair< Key, Mount > >::other> | |
HashTable< Key, Mount, OtherAlloc > | map (const Mount &val, Size size=Size(0), bool resize_pol=HashTableConst::default_resize_policy, bool key_uniqueness_pol=HashTableConst::default_uniqueness_policy) const |
Creates a hashtable of mounts with a given value from a hashtable of vals. More... | |
Public Types | |
using | Bucket = HashTableBucket< Key, Val > |
The buckets where data are stored. More... | |
using | BucketAllocator = typename Alloc::template rebind< Bucket >::other |
The Bucket allocator. More... | |
using | key_type = Key |
Types for STL compliance. More... | |
using | mapped_type = Val |
Types for STL compliance. More... | |
using | value_type = std::pair< const Key, Val > |
Types for STL compliance. More... | |
using | reference = value_type & |
Types for STL compliance. More... | |
using | const_reference = const value_type & |
Types for STL compliance. More... | |
using | pointer = value_type * |
Types for STL compliance. More... | |
using | const_pointer = const value_type * |
Types for STL compliance. More... | |
using | size_type = Size |
Types for STL compliance. More... | |
using | difference_type = std::ptrdiff_t |
Types for STL compliance. More... | |
using | allocator_type = Alloc |
Types for STL compliance. More... | |
using | iterator = HashTableIterator< Key, Val > |
Types for STL compliance. More... | |
using | const_iterator = HashTableConstIterator< Key, Val > |
Types for STL compliance. More... | |
using | iterator_safe = HashTableIteratorSafe< Key, Val > |
Types for STL compliance. More... | |
using | const_iterator_safe = HashTableConstIteratorSafe< Key, Val > |
Types for STL compliance. More... | |
Friends | |
template<typename K , typename V , typename A > | |
class | HashTable |
Friends to optimize the access to data, iterators must be friends. More... | |
class | HashTableIterator< Key, Val > |
Friends to optimize the access to data, iterators must be friends. More... | |
class | HashTableConstIterator< Key, Val > |
Friends to optimize the access to data, iterators must be friends. More... | |
class | HashTableIteratorSafe< Key, Val > |
Friends to optimize the access to data, iterators must be friends. More... | |
class | HashTableConstIteratorSafe< Key, Val > |
Friends to optimize the access to data, iterators must be friends. More... | |
template<typename T1 , typename T2 , typename A > | |
class | Bijection |
For bijections to quickly access data. More... | |
std::ostream & | operator<< (std::ostream &, const HashTable< Key, Val, Alloc > &) |
Prints the content of a gum::HashTable in the stream. More... | |
std::ostream & | operator<< (std::ostream &s, const HashTable< Key *, Val, Alloc > &table) |
Prints the content of a gum::HashTable with pointers key in the stream. More... | |
Iterators | |
const iterator & | end () noexcept |
Returns the unsafe iterator pointing to the end of the hashtable. More... | |
const const_iterator & | end () const noexcept |
Returns the unsafe const_iterator pointing to the end of the hashtable. More... | |
const const_iterator & | cend () const noexcept |
Returns the unsafe const_iterator pointing to the end of the hashtable. More... | |
iterator | begin () |
Returns an unsafe iterator pointing to the beginning of the hashtable. More... | |
const_iterator | begin () const |
Returns an unsafe const_iterator pointing to the beginning of the hashtable. More... | |
const_iterator | cbegin () const |
Returns an unsafe const_iterator pointing to the beginning of the hashtable. More... | |
const iterator_safe & | endSafe () noexcept |
Returns the safe iterator pointing to the end of the hashtable. More... | |
const const_iterator_safe & | endSafe () const noexcept |
Returns the safe const_iterator pointing to the end of the hashtable. More... | |
const const_iterator_safe & | cendSafe () const noexcept |
Returns the safe const_iterator pointing to the end of the hashtable. More... | |
iterator_safe | beginSafe () |
Returns the safe iterator pointing to the beginning of the hashtable. More... | |
const_iterator_safe | beginSafe () const |
Returns the safe const_iterator pointing to the beginning of the hashtable. More... | |
const_iterator_safe | cbeginSafe () const |
Returns the safe const_iterator pointing to the beginning of the hashtable. More... | |
static const iterator & | end4Statics () |
Returns the end iterator for other classes' statics (read the detailed description of this method). More... | |
static const const_iterator & | constEnd4Statics () |
Returns the end iterator for other classes' statics (read the detailed description of this method). More... | |
static const iterator_safe & | endSafe4Statics () |
Returns the end iterator for other classes' statics (read the detailed description of this method). More... | |
static const const_iterator_safe & | constEndSafe4Statics () |
Returns the end iterator for other classes' statics (read the detailed description of this method). More... | |
The class for generic Hash Tables.
In aGrUM, a hashtable is a vector of chained lists (collision problems are fixed by chaining). Each slot of the vector contains a list of elements sharing the same hashed value. To be computationally efficient, the hash table should not contain too many elements as compared to its number of slots. Therefore, it is sometimes useful to resize the chained lists vector. aGrUM's hash tables are designed to automatically double their size when there is in average more than 3 elements per slot. However, when memory consumption is a concern, this feature can be turned off either by passing false as an optional resize_pol argument to the constructor of the hash table or by using method setResizePolicy when the instance of the class has already been constructed. Similarly, the default number of slots of the hash table may be parameterized as an optional argument of the constructor (size_param). Beware: when inserting elements of a given class into a hash table, unless the element is an r-value, only a copy of this element is stored into the table (this is compulsory if the hashtable is to be generic and can be used to store both complex classes and built-in types like integers). HashTable have different kinds of iterators: HashTableIteratorSafe and HashTableConstIteratorSafe (a.k.a. HashTable<>::iterator_safe and HashTable<>::const_iterator_safe) allow safe parsing of the hash tables. By safe, we mean that whenever the element pointed to by such an iterator is removed from the hashtable, accessing it through the iterator (*iter) does not result in a segmentation fault but rather in an exception being thrown. This safety is ensured at a very low cost (actually, our experiments show that our HashTables and HashTable's safe iterators significantly outperform the standard library unordered_maps). Of course, if there is no possibility for an iterator to point to a deleted element, the user can use "unsafe" iterators HashTableIterator and HashTableConstIterator (a.k.a. HashTable<>::iterator and HashTable<>::const_iterator). These iterators are slightly faster than their safe counterparts. However, as in the standard library, accessing through them a deleted element usually results in a mess (most probably a segfault).
Key | The type for keys in a gum::HashTable. |
Val | The type for values in a gum::HashTable. |
Alloc | The gum::HashTable allocator. |
Definition at line 666 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::allocator_type = Alloc |
Types for STL compliance.
Definition at line 679 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::Bucket = HashTableBucket< Key, Val > |
The buckets where data are stored.
Definition at line 687 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::BucketAllocator = typename Alloc::template rebind< Bucket >::other |
The Bucket allocator.
Definition at line 690 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::const_iterator = HashTableConstIterator< Key, Val > |
Types for STL compliance.
Definition at line 681 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::const_iterator_safe = HashTableConstIteratorSafe< Key, Val > |
Types for STL compliance.
Definition at line 683 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::const_pointer = const value_type* |
Types for STL compliance.
Definition at line 676 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::const_reference = const value_type& |
Types for STL compliance.
Definition at line 674 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::difference_type = std::ptrdiff_t |
Types for STL compliance.
Definition at line 678 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::iterator = HashTableIterator< Key, Val > |
Types for STL compliance.
Definition at line 680 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::iterator_safe = HashTableIteratorSafe< Key, Val > |
Types for STL compliance.
Definition at line 682 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::key_type = Key |
Types for STL compliance.
Definition at line 670 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::mapped_type = Val |
Types for STL compliance.
Definition at line 671 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::pointer = value_type* |
Types for STL compliance.
Definition at line 675 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::reference = value_type& |
Types for STL compliance.
Definition at line 673 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::size_type = Size |
Types for STL compliance.
Definition at line 677 of file hashTable.h.
using gum::HashTable< Key, Val, Alloc >::value_type = std::pair< const Key, Val > |
Types for STL compliance.
Definition at line 672 of file hashTable.h.
|
explicit |
Default constructor.
The true capacity (vector's size) of the hashtable will be the lowest number greater than or equal to size_param that is also a power of 2. The second optional argument is the resizing policy. By default, each time there is an average of 3 elements by node, the size of the hashtable is automatically multiplied by 2. But the user may pass false as argument to resize_pol to disable this feature.
size_param | The initial size of the gum::HashTable. |
resize_pol | The policy for resizing the hashtable when new elements are added (possible values: true = automatic resize and false = manual resize). |
key_uniqueness_pol | Uniqueness policy : should we prevent inserting the same key more than once in the table? |
Definition at line 366 of file hashTable_tpl.h.
|
explicit |
Initializer list constructor.
list | The initialized list. |
Definition at line 380 of file hashTable_tpl.h.
gum::HashTable< Key, Val, Alloc >::HashTable | ( | const HashTable< Key, Val, Alloc > & | from | ) |
Copy constructor.
This creates a new hashtable the content of which is similar to that of the table passed in argument. Beware: similar does not mean that both tables share the same objects, but rather that the objects stored in the newly created table are copies of those of the table passed in argument. In particular, the new hash table inherits the parameters (resize policy, uniqueness policy) of table 'from'.
from | The gum::HashTable to copy. |
Definition at line 396 of file hashTable_tpl.h.
gum::HashTable< Key, Val, Alloc >::HashTable | ( | const HashTable< Key, Val, OtherAlloc > & | from | ) |
Generalized copy constructor.
This creates a new hashtable the content of which is similar to that of the table passed in argument. Beware: similar does not mean that both tables share the same objects, but rather that the objects stored in the newly created table are copies of those of the table passed in argument. In particular, the new hash table inherits the parameters (resize policy, uniqueness policy) of table 'table'
from | The gum::HashTable to copy. |
Definition at line 411 of file hashTable_tpl.h.
gum::HashTable< Key, Val, Alloc >::HashTable | ( | HashTable< Key, Val, Alloc > && | from | ) |
Move constructor.
from | The gum::HashTable to move. |
Definition at line 425 of file hashTable_tpl.h.
INLINE gum::HashTable< Key, Val, Alloc >::~HashTable | ( | ) |
Class destructor.
Definition at line 457 of file hashTable_tpl.h.
|
private |
Clear all the safe iterators.
Definition at line 436 of file hashTable_tpl.h.
|
private |
A function used to perform copies of HashTables.
This code is shared by the copy constructor and the copy operator. The function ensures that when a memory allocation problem occurs:
The function assumes that both this and table have arrays ' __nodes' of the same size.
table | The gum::HashTable to copy. |
OtherAlloc | The other gum::HashTable allocator. |
Definition at line 296 of file hashTable_tpl.h.
|
private |
Used by all default constructors (general and specialized).
size | The size of the gum::HashTable to create. |
Definition at line 349 of file hashTable_tpl.h.
|
private |
Erases a given bucket.
Definition at line 954 of file hashTable_tpl.h.
|
private |
Adds a new element (actually a copy of this element) in the hash table.
If there already exists an element with the same key in the list and the uniqueness policy prevents multiple identical keys to belong to the same hashtable, an exception DuplicateElement is thrown. If the uniqueness policy is not set, the method runs in the worst case in constant time, else if the automatic resizing policy is set, it runs in constant time in average linear in the number of elements by slot.
bucket | The bucket inserted in the hash table. |
DuplicateElement | is thrown when attempting to insert a pair (key,val) in a hash table containing already a pair with the same key and when the hash table's uniqueness policy is set. |
Definition at line 806 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::iterator gum::HashTable< Key, Val, Alloc >::begin | ( | ) |
Returns an unsafe iterator pointing to the beginning of the hashtable.
Unsafe iterators are slightly faster than safe iterators. However, BE CAREFUL when using them: they should ONLY be used when you have the guarantee that they will never point to a deleted element. If unsure, prefer using the safe iterators (those are only slightly slower).
Definition at line 606 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::const_iterator gum::HashTable< Key, Val, Alloc >::begin | ( | ) | const |
Returns an unsafe const_iterator pointing to the beginning of the hashtable.
Unsafe iterators are slightly faster than safe iterators. However, BE CAREFUL when using them: they should ONLY be used when you have the guarantee that they will never point to a deleted element. If unsure, prefer using the safe iterators (those are only slightly slower).
Definition at line 616 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::iterator_safe gum::HashTable< Key, Val, Alloc >::beginSafe | ( | ) |
Returns the safe iterator pointing to the beginning of the hashtable.
Safe iterators are slightly slower than unsafe ones but they guarantee that you will never get a segfault if they try to access to a deleted element or if they try a ++ operation from a deleted element.
Definition at line 666 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::const_iterator_safe gum::HashTable< Key, Val, Alloc >::beginSafe | ( | ) | const |
Returns the safe const_iterator pointing to the beginning of the hashtable.
Safe iterators are slightly slower than unsafe ones but they guarantee that you will never get a segfault if they try to access to a deleted element or if they try a ++ operation from a deleted element.
Definition at line 676 of file hashTable_tpl.h.
|
noexcept |
Returns the number of slots in the 'nodes' vector of the hashtable.
The method runs in constant time.
Definition at line 710 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::const_iterator gum::HashTable< Key, Val, Alloc >::cbegin | ( | ) | const |
Returns an unsafe const_iterator pointing to the beginning of the hashtable.
Unsafe iterators are slightly faster than safe iterators. However, BE CAREFUL when using them: they should ONLY be used when you have the guarantee that they will never point to a deleted element. If unsure, prefer using the safe iterators (those are only slightly slower).
Definition at line 626 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::const_iterator_safe gum::HashTable< Key, Val, Alloc >::cbeginSafe | ( | ) | const |
Returns the safe const_iterator pointing to the beginning of the hashtable.
Safe iterators are slightly slower than unsafe ones but they guarantee that you will never get a segfault if they try to access to a deleted element or if they try a ++ operation from a deleted element.
Definition at line 686 of file hashTable_tpl.h.
|
noexcept |
Returns the unsafe const_iterator pointing to the end of the hashtable.
Unsafe iterators are slightly faster than safe iterators. However, BE CAREFUL when using them: they should ONLY be used when you have the guarantee that they will never point to a deleted element. If unsure, prefer using the safe iterators (those are only slightly slower).
Definition at line 597 of file hashTable_tpl.h.
|
noexcept |
Returns the safe const_iterator pointing to the end of the hashtable.
Safe iterators are slightly slower than unsafe ones but they guarantee that you will never get a segfault if they try to access to a deleted element or if they try a ++ operation from a deleted element.
Definition at line 656 of file hashTable_tpl.h.
INLINE void gum::HashTable< Key, Val, Alloc >::clear | ( | ) |
Removes all the elements in the hash table.
The function does not resize the nodes vector (even if the size of this one has been increased after the creation of the hash table) and it resets the iterators on the hash table to end. The method runs in linear time w.r.t. the number of iterators pointing to the hash table.
Definition at line 443 of file hashTable_tpl.h.
|
static |
Returns the end iterator for other classes' statics (read the detailed description of this method).
To reduce memory consumption of hash tables (which are heavily used in aGrUM) while allowing fast for(iter=begin(); iter!=end();++iter) loops, end iterators are created just once as a static member of a non-template hashtable. While this scheme is efficient and it works quite effectively when manipulating hashtables, it has a drawback: other classes with static members using the HashTable's end() iterator may fail to work due to the well known "static initialization order fiasco" (see Marshall Cline's C++ FAQ for more details about this C++ feature). OK, so what is the problem? Consider for instance class Set. A Set contains a hashtable that stores all its elements in a convenient way. To reduce memory consumption, Set::end iterator is a static member that is initialized with a HashTable's end iterator. If the compiler decides to initialize Set::end before initializing HashTable::end, then Set::end will be in an incoherent state. Unfortunately, we cannot know for sure in which order static members will be initialized (the order is a compiler's decision). Hence, we shall enforce the fact that HashTable::end is initialized before Set::end. Using method HashTable::end4Statics will ensure this fact: it uses the C++ "construct on first use" idiom (see the C++ FAQ) that ensures that the order fiasco is avoided. More precisely, end4Statics initializes a global variable that is the very end iterator used by all hashtables. Now, this induces a small overhead. So, we also provide a HashTable::end() method that returns the end iterator without this small overhead, but assuming that function end4Statics has already been called once (which is always the case) when a hashtable has been created.
So, to summarize: when initializing static members, use constEnd4Statics() rather than cend(). In all the other cases, use simply the usual method cend().
Definition at line 329 of file hashTable_tpl.h.
|
static |
Returns the end iterator for other classes' statics (read the detailed description of this method).
To reduce memory consumption of hash tables (which are heavily used in aGrUM) while allowing fast for(iter=begin(); iter!=end();++iter) loops, end iterators are created just once as a static member of a non-template hashtable. While this scheme is efficient and it works quite effectively when manipulating hashtables, it has a drawback: other classes with static members using the HashTable's end() iterator may fail to work due to the well known "static initialization order fiasco" (see Marshall Cline's C++ FAQ for more details about this C++ feature). OK, so what is the problem? Consider for instance class Set. A Set contains a hashtable that stores all its elements in a convenient way. To reduce memory consumption, Set::end iterator is a static member that is initialized with a HashTable's end iterator. If the compiler decides to initialize Set::end before initializing HashTable::end, then Set::end will be in an incoherent state. Unfortunately, we cannot know for sure in which order static members will be initialized (the order is a compiler's decision). Hence, we shall enforce the fact that HashTable::end is initialized before Set::end. Using method HashTable::end4Statics will ensure this fact: it uses the C++ "construct on first use" idiom (see the C++ FAQ) that ensures that the order fiasco is avoided. More precisely, end4Statics initializes a global variable that is the very end iterator used by all hashtables. Now, this induces a small overhead. So, we also provide a HashTable::end() method that returns the end iterator without this small overhead, but assuming that function end4Statics has already been called once (which is always the case) when a hashtable has been created.
So, to summarize: when initializing static members, use constEndSafe4Statics() rather than cendSafe(). In all the other cases, use simply the usual method cendSafe().
Definition at line 343 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::value_type& gum::HashTable< Key, Val, Alloc >::emplace | ( | Args &&... | args | ) |
Definition at line 905 of file hashTable_tpl.h.
value_type& gum::HashTable< Key, Val, Alloc >::emplace | ( | Args &&... | args | ) |
Emplace a new element into the hashTable.
If there already exists an element with the same key in the list and the uniqueness policy prevents multiple identical keys to belong to the same hashtable, an exception DuplicateElement is thrown. If the uniqueness policy is not set, the method runs in the worst case in constant time, else if the automatic resizing policy is set, it runs in constant time in average linear in the number of elements by slot.
DuplicateElement | is thrown when attempting to insert a pair (key,val) in a hash table containing already a pair with the same key and when the hash table's uniqueness policy is set. |
args | The element to emplace. |
|
noexcept |
Indicates whether the hash table is empty.
Definition at line 1042 of file hashTable_tpl.h.
|
noexcept |
Returns the unsafe iterator pointing to the end of the hashtable.
Unsafe iterators are slightly faster than safe iterators. However, BE CAREFUL when using them: they should ONLY be used when you have the guarantee that they will never point to a deleted element. If unsure, prefer using the safe iterators (those are only slightly slower).
Definition at line 578 of file hashTable_tpl.h.
|
noexcept |
Returns the unsafe const_iterator pointing to the end of the hashtable.
Unsafe iterators are slightly faster than safe iterators. However, BE CAREFUL when using them: they should ONLY be used when you have the guarantee that they will never point to a deleted element. If unsure, prefer using the safe iterators (those are only slightly slower).
Definition at line 587 of file hashTable_tpl.h.
|
static |
Returns the end iterator for other classes' statics (read the detailed description of this method).
To reduce memory consumption of hash tables (which are heavily used in aGrUM) while allowing fast for(iter=begin(); iter!=end();++iter) loops, end iterators are created just once as a static member of a non-template hashtable. While this scheme is efficient and it works quite effectively when manipulating hashtables, it has a drawback: other classes with static members using the HashTable's end() iterator may fail to work due to the well known "static initialization order fiasco" (see Marshall Cline's C++ FAQ for more details about this C++ feature). OK, so what is the problem? Consider for instance class Set. A Set contains a hashtable that stores all its elements in a convenient way. To reduce memory consumption, Set::end iterator is a static member that is initialized with a HashTable's end iterator. If the compiler decides to initialize Set::end before initializing HashTable::end, then Set::end will be in an incoherent state. Unfortunately, we cannot know for sure in which order static members will be initialized (the order is a compiler's decision). Hence, we shall enforce the fact that HashTable::end is initialized before Set::end. Using method HashTable::end4Statics will ensure this fact: it uses the C++ "construct on first use" idiom (see the C++ FAQ) that ensures that the order fiasco is avoided. More precisely, end4Statics initializes a global variable that is the very end iterator used by all hashtables. Now, this induces a small overhead. So, we also provide a HashTable::end() method that returns the end iterator without this small overhead, but assuming that function end4Statics has already been called once (which is always the case) when a hashtable has been created.
So, to summarize: when initializing static members, use end4Statics() rather than end(). In all the other cases, use simply the usual method end().
Definition at line 323 of file hashTable_tpl.h.
|
noexcept |
Returns the safe iterator pointing to the end of the hashtable.
Safe iterators are slightly slower than unsafe ones but they guarantee that you will never get a segfault if they try to access to a deleted element or if they try a ++ operation from a deleted element.
Definition at line 636 of file hashTable_tpl.h.
|
noexcept |
Returns the safe const_iterator pointing to the end of the hashtable.
Safe iterators are slightly slower than unsafe ones but they guarantee that you will never get a segfault if they try to access to a deleted element or if they try a ++ operation from a deleted element.
Definition at line 646 of file hashTable_tpl.h.
|
static |
Returns the end iterator for other classes' statics (read the detailed description of this method).
To reduce memory consumption of hash tables (which are heavily used in aGrUM) while allowing fast for(iter=begin(); iter!=end();++iter) loops, end iterators are created just once as a static member of a non-template hashtable. While this scheme is efficient and it works quite effectively when manipulating hashtables, it has a drawback: other classes with static members using the HashTable's end() iterator may fail to work due to the well known "static initialization order fiasco" (see Marshall Cline's C++ FAQ for more details about this C++ feature). OK, so what is the problem? Consider for instance class Set. A Set contains a hashtable that stores all its elements in a convenient way. To reduce memory consumption, Set::end iterator is a static member that is initialized with a HashTable's end iterator. If the compiler decides to initialize Set::end before initializing HashTable::end, then Set::end will be in an incoherent state. Unfortunately, we cannot know for sure in which order static members will be initialized (the order is a compiler's decision). Hence, we shall enforce the fact that HashTable::end is initialized before Set::end. Using method HashTable::end4Statics will ensure this fact: it uses the C++ "construct on first use" idiom (see the C++ FAQ) that ensures that the order fiasco is avoided. More precisely, end4Statics initializes a global variable that is the very end iterator used by all hashtables. Now, this induces a small overhead. So, we also provide a HashTable::end() method that returns the end iterator without this small overhead, but assuming that function end4Statics has already been called once (which is always the case) when a hashtable has been created.
So, to summarize: when initializing static members, use endSafe4Statics() rather than endSafe(). In all the other cases, use simply the usual method endSafe().
Definition at line 336 of file hashTable_tpl.h.
INLINE void gum::HashTable< Key, Val, Alloc >::erase | ( | const Key & | key | ) |
Removes a given element from the hash table.
The element is the first one encountered in the list (from begin() to end()) having the specified key. If no such element can be found, nothing is done (in particular, it does not throw any exception). The function never resizes the nodes vector (even if the resizing policy would enable to decrease this size). The method runs in average in time linear to the number of iterators pointing to the table if the automatic resizing policy is set (else it is in linear time in the number of elements of the hash table plus the number of iterators).
key | The key of the element to remove. |
Definition at line 982 of file hashTable_tpl.h.
INLINE void gum::HashTable< Key, Val, Alloc >::erase | ( | const iterator_safe & | iter | ) |
Removes a given element from the hash table.
This method updates all the safe iterators pointing to the deleted element, i.e., when trying to dereference those iterators, an exception will be raised because they will know that the element they point to no longer exists.
iter | An iterator over the element to remove. |
Definition at line 993 of file hashTable_tpl.h.
INLINE void gum::HashTable< Key, Val, Alloc >::erase | ( | const const_iterator_safe & | iter | ) |
Removes a given element from the hash table.
This method updates all the safe iterators pointing to the deleted element, i.e., when trying to dereference those iterators, an exception will be raised because they will know that the element they point to no longer exists.
iter | An iterator over the element to remove. |
Definition at line 998 of file hashTable_tpl.h.
void gum::HashTable< Key, Val, Alloc >::eraseAllVal | ( | const Val & | val | ) |
Removes all the elements having a certain value from the hash table.
If no such element can be found, nothing is done (in particular, it does not throw any exception). The function never resizes the nodes vector (even if the resizing policy would enable to decrease this size). Comparisons between Val instances are performed through == operators.
val | The value to remove. |
Definition at line 1035 of file hashTable_tpl.h.
INLINE void gum::HashTable< Key, Val, Alloc >::eraseByVal | ( | const Val & | val | ) |
Removes a given element from the hash table.
The element is the first one encountered in the list (from begin() to end()) having the specified value. If no such element can be found, nothing is done (in particular, it does not throw any exception). The function never resizes the nodes vector (even if the resizing policy would enable to decrease this size). Comparisons between Val instances are performed through == operators. Logically, this method should have been named "erase", however, this would have prevented creating hash tables where both keys and vals have the same type. Hence we chose to add "ByVal" after erase to make a difference between erasing by key and erasing by val.
val | The value to remove. |
Definition at line 1003 of file hashTable_tpl.h.
INLINE bool gum::HashTable< Key, Val, Alloc >::exists | ( | const Key & | key | ) | const |
Checks whether there exists an element with a given key in the hashtable.
The method runs in average in constant time if the resizing policy is set.
key | The key to test for existence. |
Definition at line 715 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::mapped_type & gum::HashTable< Key, Val, Alloc >::getWithDefault | ( | const Key & | key, |
const Val & | default_value | ||
) |
Returns a reference on the element the key of which is passed in argument.
In case of multiple identical keys in the hash table, the first value encountered is returned. The method runs in constant time. In case of not found key, (key,default_value) is inserted in *this.
key | The key for wich we want the value. |
default_value | The default value to return if key does not match any value. |
Definition at line 923 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::mapped_type & gum::HashTable< Key, Val, Alloc >::getWithDefault | ( | Key && | key, |
Val && | default_value | ||
) |
Returns a reference on the element the key of which is passed in argument.
In case of multiple identical keys in the hash table, the first value encountered is returned. The method runs in constant time. In case of not found key, (key,default_value) is inserted in *this.
key | The key for wich we want the value. |
default_value | The default value to return if key does not match any value. |
Definition at line 934 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::value_type & gum::HashTable< Key, Val, Alloc >::insert | ( | const Key & | key, |
const Val & | val | ||
) |
Adds a new element (actually a copy of this element) into the hash table.
If there already exists an element with the same key in the table and the uniqueness policy prevents multiple identical keys to belong to the same hashtable, an exception DuplicateElement is thrown. If the uniqueness policy is not set, the method runs in the worst case in constant time, else if the automatic resizing policy is set, it runs in constant time in average linear in the number of elements by slot.
DuplicateElement | is thrown when attempting to insert a pair (key,val) in a hash table containing already a pair with the same key and when the hash table's uniqueness policy is set. |
key | The key to add. |
val | The value to add. |
Definition at line 840 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::value_type & gum::HashTable< Key, Val, Alloc >::insert | ( | Key && | key, |
Val && | val | ||
) |
Moves a new element in the hash table.
If there already exists an element with the same key in the table and the uniqueness policy prevents multiple identical keys to belong to the same hashtable, an exception DuplicateElement is thrown. If the uniqueness policy is not set, the method runs in the worst case in constant time, else if the automatic resizing policy is set, it runs in constant time in average linear in the number of elements by slot.
DuplicateElement | is thrown when attempting to insert a pair (key,val) in a hash table containing already a pair with the same key and when the hash table's uniqueness policy is set. |
key | The key to move. |
val | The value to move. |
Definition at line 856 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::value_type & gum::HashTable< Key, Val, Alloc >::insert | ( | const std::pair< Key, Val > & | elt | ) |
Adds a new element (actually a copy of this element) into the hash table.
If there already exists an element with the same key in the table and the uniqueness policy prevents multiple identical keys to belong to the same hashtable, an exception DuplicateElement is thrown. If the uniqueness policy is not set, the method runs in the worst case in constant time, else if the automatic resizing policy is set, it runs in constant time in average linear in the number of elements by slot.
DuplicateElement | is thrown when attempting to insert a pair (key,val) in a hash table containing already a pair with the same key and when the hash table's uniqueness policy is set. |
elt | The pair of key value to add. |
Definition at line 872 of file hashTable_tpl.h.
INLINE HashTable< Key, Val, Alloc >::value_type & gum::HashTable< Key, Val, Alloc >::insert | ( | std::pair< Key, Val > && | elt | ) |
Moves a new element in the hash table.
If there already exists an element with the same key in the table and the uniqueness policy prevents multiple identical keys to belong to the same hashtable, an exception DuplicateElement is thrown. If the uniqueness policy is not set, the method runs in the worst case in constant time, else if the automatic resizing policy is set, it runs in constant time in average linear in the number of elements by slot.
DuplicateElement | is thrown when attempting to insert a pair (key,val) in a hash table containing already a pair with the same key and when the hash table's uniqueness policy is set. |
elt | The pair of key value to move in this gum::HashTable. |
Definition at line 888 of file hashTable_tpl.h.
INLINE const Key & gum::HashTable< Key, Val, Alloc >::key | ( | const Key & | key | ) | const |
Returns a reference on a given key.
Some complex structures use pointers on keys of hashtables. These structures thus require that we do not only get a copy of a given key, but the key stored in the hashtable itself. This is the very purpose of this function.
key | The key to return. |
NotFound | Raised if the element cannot be found. |
Definition at line 1025 of file hashTable_tpl.h.
INLINE const Key & gum::HashTable< Key, Val, Alloc >::keyByVal | ( | const Val & | val | ) | const |
Returns a reference on the key given a value.
In case of multiple identical values in the hash table, the first key encountered is returned. The method runs in linear time.
val | The value for which the key is returned. |
NotFound | Raised if the element cannot be found. |
Definition at line 1017 of file hashTable_tpl.h.
|
noexcept |
Returns the current checking policy.
Definition at line 735 of file hashTable_tpl.h.
HashTable< Key, Mount, OtherAlloc > INLINE gum::HashTable< Key, Val, Alloc >::map | ( | Mount(*)(Val) | f, |
Size | size, | ||
bool | resize_pol, | ||
bool | key_uniqueness_pol | ||
) | const |
Definition at line 1049 of file hashTable_tpl.h.
HashTable< Key, Mount, OtherAlloc > INLINE gum::HashTable< Key, Val, Alloc >::map | ( | Mount(*)(Val &) | f, |
Size | size, | ||
bool | resize_pol, | ||
bool | key_uniqueness_pol | ||
) | const |
Definition at line 1073 of file hashTable_tpl.h.
HashTable< Key, Mount, OtherAlloc > INLINE gum::HashTable< Key, Val, Alloc >::map | ( | Mount(*)(const Val &) | f, |
Size | size, | ||
bool | resize_pol, | ||
bool | key_uniqueness_pol | ||
) | const |
Definition at line 1097 of file hashTable_tpl.h.
HashTable< Key, Mount, OtherAlloc > INLINE gum::HashTable< Key, Val, Alloc >::map | ( | const Mount & | val, |
Size | size, | ||
bool | resize_pol, | ||
bool | key_uniqueness_pol | ||
) | const |
Definition at line 1121 of file hashTable_tpl.h.
HashTable< Key, Mount, OtherAlloc > gum::HashTable< Key, Val, Alloc >::map | ( | Mount(*)(Val) | f, |
Size | size = Size(0) , |
||
bool | resize_pol = HashTableConst::default_resize_policy , |
||
bool | key_uniqueness_pol = HashTableConst::default_uniqueness_policy |
||
) | const |
Transforms a hashtable of vals into a hashtable of mountains.
f | A function that maps any Val element into a Mount. |
size | The size of the resulting hashtable. When equal to 0, a default size is computed that is a good trade-off between space consumption and efficiency of new elements insertions |
resize_pol | the resizing policy (automatic or manual resizing) |
key_uniqueness_pol | uniqueness policy |
HashTable< Key, Mount, OtherAlloc > gum::HashTable< Key, Val, Alloc >::map | ( | Mount(*)(Val &) | f, |
Size | size = Size(0) , |
||
bool | resize_pol = HashTableConst::default_resize_policy , |
||
bool | key_uniqueness_pol = HashTableConst::default_uniqueness_policy |
||
) | const |
Transforms a hashtable of vals into a hashtable of mountains.
f | A function that maps any Val element into a Mount. |
size | The size of the resulting hashtable. When equal to 0, a default size is computed that is a good trade-off between space consumption and efficiency of new elements insertions |
resize_pol | the resizing policy (automatic or manual resizing) |
key_uniqueness_pol | uniqueness policy |
HashTable< Key, Mount, OtherAlloc > gum::HashTable< Key, Val, Alloc >::map | ( | Mount(*)(const Val &) | f, |
Size | size = Size(0) , |
||
bool | resize_pol = HashTableConst::default_resize_policy , |
||
bool | key_uniqueness_pol = HashTableConst::default_uniqueness_policy |
||
) | const |
Transforms a hashtable of vals into a hashtable of mountains.
f | A function that maps any Val element into a Mount. |
size | The size of the resulting hashtable. When equal to 0, a default size is computed that is a good trade-off between space consumption and efficiency of new elements insertions |
resize_pol | the resizing policy (automatic or manual resizing) |
key_uniqueness_pol | uniqueness policy |
HashTable< Key, Mount, OtherAlloc > gum::HashTable< Key, Val, Alloc >::map | ( | const Mount & | val, |
Size | size = Size(0) , |
||
bool | resize_pol = HashTableConst::default_resize_policy , |
||
bool | key_uniqueness_pol = HashTableConst::default_uniqueness_policy |
||
) | const |
Creates a hashtable of mounts with a given value from a hashtable of vals.
val | The value taken by all the elements of the resulting hashtable. |
size | The size of the resulting hashtable. When equal to 0, a default size is computed that is a good trade-off between space consumption and efficiency of new elements insertions |
resize_pol | the resizing policy (automatic or manual resizing) |
key_uniqueness_pol | uniqueness policy |
INLINE bool gum::HashTable< Key, Val, Alloc >::operator!= | ( | const HashTable< Key, Val, OtherAlloc > & | from | ) | const |
Definition at line 1162 of file hashTable_tpl.h.
bool gum::HashTable< Key, Val, Alloc >::operator!= | ( | const HashTable< Key, Val, OtherAlloc > & | from | ) | const |
Checks whether two hashtables contain different sets of elements.
Two hashtables are considered different if they contain different pairs (key,val). Two pairs are different if their keys have different hashed values, or if they are different in the sense of !=, or if their val's are different in the sense of !=.
from | The gum::HashTable to test for inequality. |
HashTable< Key, Val, Alloc > & gum::HashTable< Key, Val, Alloc >::operator= | ( | const HashTable< Key, Val, Alloc > & | from | ) |
Copy operator.
The copy operators ensures that whenever a memory allocation problem occurs, no memory leak occurs as well and it also guarantees that in this case the hashtable returned is in a coherent state (it is an empty hashtable). Note that the copy not only involves copying pairs (key,value) but also the copy of the resize and key uniqueness policies.
from | The gum::HashTable to copy. |
Definition at line 468 of file hashTable_tpl.h.
HashTable< Key, Val, Alloc > & gum::HashTable< Key, Val, Alloc >::operator= | ( | const HashTable< Key, Val, OtherAlloc > & | from | ) |
Generalized copy operator.
The copy operators ensures that whenever a memory allocation problem occurs, no memory leak occurs as well and it also guarantees that in this case the hashtable returned is in a coherent state (it is an empty hashtable). Note that the copy not only involves copying pairs (key,value) but also the copy of the resize and key uniqueness policies.
from | The gum::HashTable to copy. |
Definition at line 509 of file hashTable_tpl.h.
HashTable< Key, Val, Alloc > & gum::HashTable< Key, Val, Alloc >::operator= | ( | HashTable< Key, Val, Alloc > && | from | ) |
Move operator.
from | The gum::HashTable to move. |
Definition at line 549 of file hashTable_tpl.h.
bool gum::HashTable< Key, Val, Alloc >::operator== | ( | const HashTable< Key, Val, OtherAlloc > & | from | ) | const |
Checks whether two hashtables contain the same elements.
Two hashtables are considered equal if they contain the identical pairs (key,val). Two pairs are identical if their keys have the same hashed value, these two keys are equal in the sense of ==, and their val's are also equal in the sense of ==.
from | The gum::HashTable to test for equality. |
Definition at line 1145 of file hashTable_tpl.h.
INLINE Val & gum::HashTable< Key, Val, Alloc >::operator[] | ( | const Key & | key | ) |
Returns a reference on the value the key of which is passed in argument.
In case of multiple identical keys in the hash table, the first value encountered is returned. The method runs in constant time.
key | The key of the value to return. |
NotFound | exception is thrown if the element cannot be found. |
Definition at line 695 of file hashTable_tpl.h.
INLINE const Val & gum::HashTable< Key, Val, Alloc >::operator[] | ( | const Key & | key | ) | const |
returns a reference on the value the key of which is passed in argument
In case of multiple identical keys in the hash table, the first value encountered is returned. The method runs in constant time.
NotFound | exception is thrown if the element cannot be found. |
Definition at line 700 of file hashTable_tpl.h.
INLINE void gum::HashTable< Key, Val, Alloc >::reset | ( | const Key & | key | ) |
Removes a property (i.e., remove an element).
Reset removes a property (i.e., a pair (key,val)) if it exists. This is an alias for erase but it is quite convenient when dealing with "dynamic property lists".
key | The property to remove. |
Definition at line 1012 of file hashTable_tpl.h.
void gum::HashTable< Key, Val, Alloc >::resize | ( | Size | new_size | ) |
Changes the number of slots in the 'nodes' vector of the hash table.
Usually, method resize enables the user to resize manually the hashtable. When in automatic resize mode, the function will actually resize the table only if resizing policy is compatible with the new size, i.e., the new size is not so small that there would be too many elements per slot in the table (this would lead to a significant loss in performance). However, the resizing policy may be changed by using method setResizePolicy. The method runs in linear time in the size of the hashtable. Upon memory allocation problem, the fuction guarantees that no data is lost and that the hash table and its iterators are in a coherent state. In such a case, a bad_alloc exception is thrown.
new_size | The new number of slots in the gum::HashTable. |
Definition at line 740 of file hashTable_tpl.h.
|
noexcept |
Returns the current resizing policy.
Definition at line 725 of file hashTable_tpl.h.
INLINE void gum::HashTable< Key, Val, Alloc >::set | ( | const Key & | key, |
const Val & | default_value | ||
) |
Add a new property or modify it if it already existed.
When used as a "dynamic property list", it may be convenient to use this function. Function set inserts a new pair (key,val) if the key does not already exists, or it changes the value associated with key if a pair (key,val) already exists in the hash table.
key | The key of the value to add or set. |
default_value | The value to set or add. |
Definition at line 944 of file hashTable_tpl.h.
|
noexcept |
Enables the user to change dynamically the policy for checking whether there can exist several elements in the table with identical keys.
By default, we should always check that there does not exist duplicate keys. However, this test slows the insertion of elements in the table. So, when we know for sure that no duplicate key will be entered into the table, we may avoid uniqueness checks.
Definition at line 730 of file hashTable_tpl.h.
|
noexcept |
Enables the user to change dynamically the resizing policy.
In most cases, this should be useless. However, when available memory becomes rare, avoiding automatic resizing may speed-up new insertions in the table.
new_policy | The new resizing policy, true implies automatic resizing. |
Definition at line 720 of file hashTable_tpl.h.
|
noexcept |
Returns the number of elements stored into the hashtable.
The method runs in constant time.
Definition at line 705 of file hashTable_tpl.h.
|
friend |
Friends to optimize the access to data, iterators must be friends.
Definition at line 1682 of file hashTable.h.
|
friend |
For bijections to quickly access data.
Definition at line 1693 of file hashTable.h.
|
friend |
Friends to optimize the access to data, iterators must be friends.
Definition at line 1684 of file hashTable.h.
|
friend |
Friends to optimize the access to data, iterators must be friends.
Definition at line 1686 of file hashTable.h.
|
friend |
Friends to optimize the access to data, iterators must be friends.
Definition at line 1683 of file hashTable.h.
|
friend |
Friends to optimize the access to data, iterators must be friends.
Definition at line 1685 of file hashTable.h.
|
friend |
Prints the content of a gum::HashTable in the stream.
Definition at line 1201 of file hashTable_tpl.h.
|
friend |
Prints the content of a gum::HashTable with pointers key in the stream.
Definition at line 1220 of file hashTable_tpl.h.
|
private |
The allocator for the buckets.
Definition at line 1744 of file hashTable.h.
|
mutableprivate |
Returns where the begin index should be.
Beware: the beginning of a HashTable is the end of its nodes vector, i.e., the Bucket at the highest index in nodes. This enables a slightly faster parsing than if it were the lowest index.
Definition at line 1731 of file hashTable.h.
|
private |
The function used to hash keys (may change when the table is resized).
Definition at line 1709 of file hashTable.h.
|
private |
Shall we check for key uniqueness in the table?
Definition at line 1715 of file hashTable.h.
|
private |
Number of elements of type Val stored in the hash table.
Definition at line 1706 of file hashTable.h.
|
private |
The hash table is represented as a vector of chained lists.
' __nodes' is this very vector.
Definition at line 1700 of file hashTable.h.
|
private |
Is resizing performed automatically?
Definition at line 1712 of file hashTable.h.
|
mutableprivate |
The list of safe iterators pointing to the hash table.
Definition at line 1734 of file hashTable.h.
|
private |
The number of nodes in vector ' __nodes'.
Definition at line 1703 of file hashTable.h.