![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
Unsafe Const Iterators for hashtables. More...
#include <agrum/base/core/hashTable.h>
Public Types | |
| using | iterator_category = std::forward_iterator_tag |
| Types for STL compliance. | |
| using | key_type = Key |
| Types for STL compliance. | |
| using | mapped_type = Val |
| Types for STL compliance. | |
| using | value_type = std::pair< const Key, Val > |
| Types for STL compliance. | |
| using | reference = value_type& |
| Types for STL compliance. | |
| using | const_reference = const value_type& |
| Types for STL compliance. | |
| using | pointer = value_type* |
| Types for STL compliance. | |
| using | const_pointer = const value_type* |
| Types for STL compliance. | |
| using | difference_type = std::ptrdiff_t |
| Types for STL compliance. | |
Public Member Functions | |
Constructors / Destructors | |
| HashTableConstIterator () noexcept | |
| Basic constructor: creates an iterator pointing to nothing. | |
| HashTableConstIterator (const HashTable< Key, Val > &tab) noexcept | |
| Constructor for an iterator pointing to the first element of a hashtable. | |
| HashTableConstIterator (const HashTable< Key, Val > &tab, Size ind_elt) | |
| Constructor for an iterator pointing to the nth element of a hashtable. | |
| HashTableConstIterator (const HashTableConstIterator< Key, Val > &from) noexcept | |
| Copy constructor. | |
| HashTableConstIterator (HashTableConstIterator< Key, Val > &&from) noexcept | |
| Move constructor. | |
| ~HashTableConstIterator () noexcept | |
| Class destructor. | |
Accessors / Modifiers | |
| const key_type & | key () const |
| Returns the key corresponding to the element pointed to by the iterator. | |
| const mapped_type & | val () const |
| Returns the mapped value pointed to by the iterator. | |
| void | clear () noexcept |
| Makes the iterator point toward nothing (in particular, it is not related anymore to its current hash table). | |
Operators | |
| HashTableConstIterator< Key, Val > & | operator= (const HashTableConstIterator< Key, Val > &from) noexcept |
| Copy operator. | |
| HashTableConstIterator< Key, Val > & | operator= (HashTableConstIterator< Key, Val > &&from) noexcept |
| Move operator. | |
| HashTableConstIterator< Key, Val > & | operator++ () noexcept |
| Makes the iterator point to the next element in the hash table. | |
| HashTableConstIterator< Key, Val > & | operator+= (Size i) noexcept |
| Makes the iterator point to i elements further in the hashtable. | |
| HashTableConstIterator< Key, Val > | operator+ (Size i) const noexcept |
| Returns a new iterator pointing to i elements further in the hashtable. | |
| bool | operator== (const HashTableConstIterator< Key, Val > &from) const noexcept |
| Checks whether two iterators are pointing toward equal elements. | |
| const value_type & | operator* () const |
| Returns the value pointed to by the iterator. | |
Protected Member Functions | |
| HashTable< Key, Val >::Bucket * | _getBucket_ () const noexcept |
| Returns the current iterator's bucket. | |
| Size | _getIndex_ () const noexcept |
| Returns the index in the hashtable's node vector pointed to by the iterator. | |
Protected Attributes | |
| const HashTable< Key, Val > * | _table_ {nullptr} |
| The hash table the iterator is pointing to. | |
| Size | _index_ {Size(0)} |
| The index of the chained list pointed by the iterator in the array of nodes of the hash table. | |
| HashTable< Key, Val >::Bucket * | _bucket_ {nullptr} |
| The bucket in the chained list pointed to by the iterator. | |
Friends | |
| class | HashTable< Key, Val > |
| Class HashTable must be a friend because it stores iterator end and this one can be properly initialized only when the hashtable has been fully allocated. | |
| class | HashTableConstIteratorSafe< Key, Val > |
| For the safe copy constructor and operator. | |
Unsafe Const Iterators for hashtables.
HashTableConstIterator provides a fast but unsafe way to parse HashTables. They should only be used when parsing hashtables in which no element is removed from the hashtable. Removing an element where the iterator points to will mess the iterator as it will most certainly point to an unallocated memory. So, this kind of iterator should only be used when parsing "(key) constant" hash tables, e.g., when we wish to display the content of a hash table or when we wish to update the mapped values of some elements of the hash table without ever modifying their keys.
Developers may consider using HashTable<x,y>::const_iterator instead of HashTableConstIterator<x,y>.
| Key | The gum::HashTable key. |
| Val | The gum::HashTable Value. |
Definition at line 2191 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::const_pointer = const value_type* |
Types for STL compliance.
Definition at line 2202 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::const_reference = const value_type& |
Types for STL compliance.
Definition at line 2200 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::difference_type = std::ptrdiff_t |
Types for STL compliance.
Definition at line 2203 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::iterator_category = std::forward_iterator_tag |
Types for STL compliance.
Definition at line 2195 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::key_type = Key |
Types for STL compliance.
Definition at line 2196 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::mapped_type = Val |
Types for STL compliance.
Definition at line 2197 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::pointer = value_type* |
Types for STL compliance.
Definition at line 2201 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::reference = value_type& |
Types for STL compliance.
Definition at line 2199 of file hashTable.h.
| using HashTableConstIterator< Key, Val >::value_type = std::pair< const Key, Val > |
Types for STL compliance.
Definition at line 2198 of file hashTable.h.
|
explicitnoexcept |
Basic constructor: creates an iterator pointing to nothing.
Definition at line 1658 of file hashTable_tpl.h.
References HashTableConstIterator().
Referenced by HashTableConstIterator(), HashTableConstIterator(), HashTableIterator< Key, Val >::HashTableIterator(), HashTableIterator< Key, Val >::HashTableIterator(), HashTableIterator< Key, Val >::HashTableIterator(), HashTableIterator< Key, Val >::HashTableIterator(), HashTableIterator< Key, Val >::HashTableIterator(), ~HashTableConstIterator(), operator+(), operator++(), operator=(), and operator=().
|
explicitnoexcept |
Constructor for an iterator pointing to the first element of a hashtable.
| tab | The gum::HashTable to iterate over. |
Definition at line 1663 of file hashTable_tpl.h.
References _table_, and HashTable< Key, Val >.
| HashTableConstIterator< Key, Val >::HashTableConstIterator | ( | const HashTable< Key, Val > & | tab, |
| Size | ind_elt ) |
Constructor for an iterator pointing to the nth element of a hashtable.
The method runs in time linear to ind_elt.
| tab | The hash table to which the so-called element belongs. |
| ind_elt | The position of the element in the hash table (0 means the first element). |
| UndefinedIteratorValue | Raised if the element cannot be found. |
Definition at line 1690 of file hashTable_tpl.h.
References _table_, and HashTable< Key, Val >.
|
noexcept |
Copy constructor.
| from | The gum::HashTableConstIterator to copy. |
Definition at line 1748 of file hashTable_tpl.h.
|
noexcept |
Move constructor.
| from | The gum::HashTableConstIterator to move. |
Definition at line 1755 of file hashTable_tpl.h.
References HashTableConstIterator(), and _table_.
|
noexcept |
Class destructor.
Definition at line 1762 of file hashTable_tpl.h.
References HashTableConstIterator().
|
nodiscardprotectednoexcept |
Returns the current iterator's bucket.
Definition at line 1903 of file hashTable_tpl.h.
References _bucket_.
|
nodiscardprotectednoexcept |
Returns the index in the hashtable's node vector pointed to by the iterator.
Definition at line 1908 of file hashTable_tpl.h.
References _index_.
|
noexcept |
|
nodiscard |
Returns the key corresponding to the element pointed to by the iterator.
Definition at line 1786 of file hashTable_tpl.h.
| const HashTableConstIterator< Key, Val >::value_type & HashTableConstIterator< Key, Val >::operator* | ( | ) | const |
Returns the value pointed to by the iterator.
Definition at line 1896 of file hashTable_tpl.h.
References _bucket_, and GUM_ERROR.
Referenced by HashTableIterator< Key, Val >::operator*(), and HashTableIterator< Key, Val >::operator*().
|
noexcept |
Returns a new iterator pointing to i elements further in the hashtable.
| i | The number of increments. |
Definition at line 1884 of file hashTable_tpl.h.
References HashTableConstIterator().
|
noexcept |
Makes the iterator point to the next element in the hash table.
The above loop is guaranteed to parse the whole hash table as long as no element is added to or deleted from the hash table while being in the loop.
Definition at line 1806 of file hashTable_tpl.h.
References HashTableConstIterator(), and _bucket_.
Referenced by HashTableIterator< Key, Val >::operator++().
|
noexcept |
Makes the iterator point to i elements further in the hashtable.
| i | The number of increments. |
Definition at line 1852 of file hashTable_tpl.h.
References _bucket_, _index_, and _table_.
Referenced by HashTableIterator< Key, Val >::operator+=().
|
defaultnoexcept |
Copy operator.
| from | The gum::HashTableConstIterator to copy. |
References HashTableConstIterator().
Referenced by HashTableIterator< Key, Val >::operator=(), and HashTableIterator< Key, Val >::operator=().
|
noexcept |
Move operator.
| from | The gum::HashTableConstIterator to move. |
Definition at line 1772 of file hashTable_tpl.h.
References HashTableConstIterator(), _bucket_, _index_, and _table_.
|
noexcept |
Checks whether two iterators are pointing toward equal elements.
| from | The gum::HashTableConstIterator to test for equality. |
Definition at line 1889 of file hashTable_tpl.h.
Referenced by HashTableIterator< Key, Val >::operator==().
|
nodiscard |
Returns the mapped value pointed to by the iterator.
Definition at line 1793 of file hashTable_tpl.h.
|
friend |
Class HashTable must be a friend because it stores iterator end and this one can be properly initialized only when the hashtable has been fully allocated.
Thus, proper initialization can only take place within the constructor's code of the hashtable.
Definition at line 2370 of file hashTable.h.
Referenced by HashTableConstIterator(), HashTableConstIterator(), HashTableIterator< Key, Val >::HashTableIterator(), and HashTableIterator< Key, Val >::HashTableIterator().
|
friend |
For the safe copy constructor and operator.
Definition at line 2370 of file hashTable.h.
|
protected |
The bucket in the chained list pointed to by the iterator.
Definition at line 2396 of file hashTable.h.
Referenced by _getBucket_(), gum::HashTableConstIteratorSafe< const gum::DiscreteVariable *, Idx >::_getIndex_(), clear(), key(), operator*(), operator++(), operator+=(), operator=(), val(), and HashTableIterator< Key, Val >::val().
|
protected |
The index of the chained list pointed by the iterator in the array of nodes of the hash table.
Definition at line 2393 of file hashTable.h.
Referenced by _getIndex_(), clear(), operator+=(), and operator=().
|
protected |
The hash table the iterator is pointing to.
Definition at line 2387 of file hashTable.h.
Referenced by HashTableConstIterator(), HashTableConstIterator(), HashTableConstIterator(), clear(), gum::HashTable< const gum::DiscreteVariable *, Idx >::eraseByVal(), gum::HashTable< const gum::DiscreteVariable *, Idx >::key(), gum::HashTableConstIteratorSafe< const gum::DiscreteVariable *, Idx >::key(), operator+=(), and operator=().