![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Unsafe 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 | |
| mapped_type & | val () |
| Returns the mapped value pointed to by the iterator. | |
Constructors / Destructors | |
| HashTableIterator () noexcept | |
| Basic constructor: creates an iterator pointing to nothing. | |
| HashTableIterator (const HashTable< Key, Val > &tab) noexcept | |
| Constructor for an iterator pointing to the first element of a hashtable. | |
| HashTableIterator (const HashTable< Key, Val > &tab, Size ind_elt) | |
| Constructor for an iterator pointing to the nth element of a hashtable. | |
| HashTableIterator (const HashTableIterator< Key, Val > &from) noexcept | |
| Copy constructor. | |
| HashTableIterator (HashTableIterator< Key, Val > &&from) noexcept | |
| Move constructor. | |
| ~HashTableIterator () noexcept | |
| Class destructor. | |
Operators | |
| HashTableIterator< Key, Val > & | operator= (const HashTableIterator< Key, Val > &from) noexcept |
| Copy operator. | |
| HashTableIterator< Key, Val > & | operator= (HashTableIterator< Key, Val > &&from) noexcept |
| Move operator. | |
| HashTableIterator< Key, Val > & | operator++ () noexcept |
| Makes the iterator point to the next element in the hash table. | |
| HashTableIterator< Key, Val > & | operator+= (Size i) noexcept |
| Makes the iterator point to i elements further in the hashtable. | |
| HashTableIterator< Key, Val > | operator+ (Size i) const noexcept |
| Returns a new iterator. | |
| bool | operator!= (const HashTableIterator< Key, Val > &from) const noexcept |
| Checks whether two iterators are pointing toward different elements. | |
| bool | operator== (const HashTableIterator< Key, Val > &from) const noexcept |
| Checks whether two iterators are pointing toward equal elements. | |
| value_type & | operator* () |
| Returns the value pointed to by the iterator. | |
| const value_type & | operator* () const |
| Returns the value pointed to by the iterator. | |
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 | |
| bool | operator!= (const HashTableConstIterator< Key, Val > &from) const noexcept |
| Checks whether two iterators are pointing toward different elements. | |
| bool | operator== (const HashTableConstIterator< Key, Val > &from) const noexcept |
| Checks whether two iterators are pointing toward equal elements. | |
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. | |
Unsafe Iterators for hashtables.
HashTableIterator 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>::iterator instead of HashTableIterator<x,y>.
| Key | The gum::HashTable key. |
| Val | The gum::HashTable Value. |
Definition at line 2428 of file hashTable.h.
| using HashTableIterator< Key, Val >::const_pointer = const value_type* |
types for STL compliance
Definition at line 2439 of file hashTable.h.
| using HashTableIterator< Key, Val >::const_reference = const value_type& |
types for STL compliance
Definition at line 2437 of file hashTable.h.
| using HashTableIterator< Key, Val >::difference_type = std::ptrdiff_t |
types for STL compliance
Definition at line 2440 of file hashTable.h.
| using HashTableIterator< Key, Val >::iterator_category = std::forward_iterator_tag |
types for STL compliance
Definition at line 2432 of file hashTable.h.
| using HashTableIterator< Key, Val >::key_type = Key |
types for STL compliance
Definition at line 2433 of file hashTable.h.
| using HashTableIterator< Key, Val >::mapped_type = Val |
types for STL compliance
Definition at line 2434 of file hashTable.h.
| using HashTableIterator< Key, Val >::pointer = value_type* |
types for STL compliance
Definition at line 2438 of file hashTable.h.
| using HashTableIterator< Key, Val >::reference = value_type& |
types for STL compliance
Definition at line 2436 of file hashTable.h.
| using HashTableIterator< Key, Val >::value_type = std::pair< const Key, Val > |
types for STL compliance
Definition at line 2435 of file hashTable.h.
|
explicitnoexcept |
Basic constructor: creates an iterator pointing to nothing.
Definition at line 1843 of file hashTable_tpl.h.
References HashTableConstIterator< Key, Val >::HashTableConstIterator(), and HashTableIterator().
Referenced by HashTableIterator(), HashTableIterator(), HashTableIterator(), HashTableIterator(), HashTableIterator(), ~HashTableIterator(), operator!=(), operator+(), operator++(), operator=(), operator=(), and operator==().
|
noexcept |
Constructor for an iterator pointing to the first element of a hashtable.
| tab | The gum::HashTable to iterate over. |
Definition at line 1849 of file hashTable_tpl.h.
References HashTableConstIterator< Key, Val >::HashTableConstIterator(), HashTableIterator(), and HashTableConstIterator< Key, Val >::HashTable< Key, Val >.
| INLINE HashTableIterator< Key, Val >::HashTableIterator | ( | 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 1855 of file hashTable_tpl.h.
References HashTableConstIterator< Key, Val >::HashTableConstIterator(), HashTableIterator(), and HashTableConstIterator< Key, Val >::HashTable< Key, Val >.
|
noexcept |
Copy constructor.
| from | The gum::HashTableIterator to copy. |
Definition at line 1862 of file hashTable_tpl.h.
References HashTableConstIterator< Key, Val >::HashTableConstIterator(), and HashTableIterator().
|
noexcept |
Move constructor.
| from | The gum::HashTableIterator to move. |
Definition at line 1869 of file hashTable_tpl.h.
References HashTableConstIterator< Key, Val >::HashTableConstIterator(), and HashTableIterator().
|
noexcept |
Class destructor.
Definition at line 1876 of file hashTable_tpl.h.
References HashTableIterator().
|
protectednoexceptinherited |
Returns the current iterator's bucket.
Definition at line 1829 of file hashTable_tpl.h.
References _bucket_.
|
protectednoexceptinherited |
Returns the index in the hashtable's node vector pointed to by the iterator.
Definition at line 1834 of file hashTable_tpl.h.
References _index_.
|
noexceptinherited |
Makes the iterator point toward nothing (in particular, it is not related anymore to its current hash table).
Definition at line 1719 of file hashTable_tpl.h.
References _table_.
|
inherited |
Returns the key corresponding to the element pointed to by the iterator.
Definition at line 1706 of file hashTable_tpl.h.
|
noexceptinherited |
Checks whether two iterators are pointing toward different elements.
| from | The gum::HashTableConstIterator to test for inequality. |
Definition at line 1809 of file hashTable_tpl.h.
References HashTableConstIterator(), and _bucket_.
Referenced by HashTableIterator< Key, Val >::operator!=().
|
noexcept |
Checks whether two iterators are pointing toward different elements.
| from | The gum::HashTableIterator to test for inequality. |
Definition at line 1922 of file hashTable_tpl.h.
References HashTableIterator(), and HashTableConstIterator< Key, Val >::operator!=().
| INLINE HashTableIterator< Key, Val >::value_type & HashTableIterator< Key, Val >::operator* | ( | ) |
Returns the value pointed to by the iterator.
Definition at line 1935 of file hashTable_tpl.h.
References HashTableConstIterator< Key, Val >::operator*().
| INLINE const HashTableIterator< Key, Val >::value_type & HashTableIterator< Key, Val >::operator* | ( | ) | const |
Returns the value pointed to by the iterator.
Definition at line 1941 of file hashTable_tpl.h.
References HashTableConstIterator< Key, Val >::operator*().
|
noexcept |
Returns a new iterator.
| i | The number of increments. |
Definition at line 1915 of file hashTable_tpl.h.
References HashTableIterator().
|
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 1901 of file hashTable_tpl.h.
References HashTableIterator(), and HashTableConstIterator< Key, Val >::operator++().
|
noexcept |
Makes the iterator point to i elements further in the hashtable.
| i | The number of increments. |
Definition at line 1908 of file hashTable_tpl.h.
References HashTableConstIterator< Key, Val >::operator+=().
|
noexcept |
Copy operator.
| from | The gum::HashTableIterator to copy. |
Definition at line 1888 of file hashTable_tpl.h.
References HashTableIterator(), and HashTableConstIterator< Key, Val >::operator=().
|
noexcept |
Move operator.
| from | The gum::HashTableIterator to move. |
Definition at line 1895 of file hashTable_tpl.h.
References HashTableIterator(), and HashTableConstIterator< Key, Val >::operator=().
|
noexceptinherited |
Checks whether two iterators are pointing toward equal elements.
| from | The gum::HashTableConstIterator to test for equality. |
Definition at line 1815 of file hashTable_tpl.h.
References HashTableConstIterator(), and _bucket_.
Referenced by HashTableIterator< Key, Val >::operator==().
|
noexcept |
Checks whether two iterators are pointing toward equal elements.
| from | The gum::HashTableIterator to test for equality. |
Definition at line 1928 of file hashTable_tpl.h.
References HashTableIterator(), and HashTableConstIterator< Key, Val >::operator==().
|
inherited |
Returns the mapped value pointed to by the iterator.
Definition at line 1713 of file hashTable_tpl.h.
| INLINE HashTableIterator< Key, Val >::mapped_type & HashTableIterator< Key, Val >::val | ( | ) |
Returns the mapped value pointed to by the iterator.
Definition at line 1881 of file hashTable_tpl.h.
References GUM_ERROR.
|
protectedinherited |
The bucket in the chained list pointed to by the iterator.
Definition at line 2359 of file hashTable.h.
Referenced by _getBucket_(), gum::HashTableConstIteratorSafe< Key, Val >::operator!=(), operator!=(), operator*(), operator++(), operator+=(), gum::HashTableConstIteratorSafe< Key, Val >::operator=(), operator=(), gum::HashTableConstIteratorSafe< Key, Val >::operator==(), operator==(), and val().
|
protectedinherited |
The index of the chained list pointed by the iterator in the array of nodes of the hash table.
Definition at line 2356 of file hashTable.h.
Referenced by _getIndex_(), gum::HashTableConstIteratorSafe< Key, Val >::operator!=(), operator++(), gum::HashTableConstIteratorSafe< Key, Val >::operator=(), operator=(), and gum::HashTableConstIteratorSafe< Key, Val >::operator==().
|
protectedinherited |
The hash table the iterator is pointing to.
Definition at line 2350 of file hashTable.h.
Referenced by HashTableConstIterator(), HashTableConstIterator(), HashTableConstIterator(), HashTableConstIterator(), clear(), operator++(), operator+=(), gum::HashTableConstIteratorSafe< Key, Val >::operator=(), gum::HashTableConstIteratorSafe< Key, Val >::operator=(), operator=(), and operator=().