Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ogdf::HashConstIterator< K, I, H > Class Template Reference

Iterators for hash tables. More...

#include <ogdf/basic/Hashing.h>

+ Inheritance diagram for ogdf::HashConstIterator< K, I, H >:

Public Member Functions

 HashConstIterator ()
 Creates a hash iterator pointing to no element.
 
 HashConstIterator (const HashConstIterator< K, I, H > &it)
 Copy constructor.
 
 HashConstIterator (HashElement< K, I > *pElement, HashElement< K, I > **pList, const Hashing< K, I, H > *pHashing)
 Creates a hash iterator pointing to element pElement in list pList of hash table pHashing.
 
const I & info () const
 Returns the information of the hash element pointed to.
 
const Kkey () const
 Returns the key of the hash element pointed to.
 
HashConstIterator< K, I, H > & operator++ ()
 Moves this hash iterator to the next element (iterator gets invalid if no more elements).
 
HashConstIteratoroperator= (const HashConstIterator< K, I, H > &it)
 Assignment operator.
 
bool valid () const
 Returns true if the hash iterator points to an element.
 

Private Attributes

HashElement< K, I > * m_pElement
 The hash element to which the iterator points.
 
const Hashing< K, I, H > * m_pHashing
 The associated hash table.
 
HashElement< K, I > ** m_pList
 The list containg the hash element.
 

Friends

bool operator!= (const HashConstIterator< K, I, H > &it1, const HashConstIterator< K, I, H > &it2)
 Inequality operator.
 
bool operator== (const HashConstIterator< K, I, H > &it1, const HashConstIterator< K, I, H > &it2)
 Equality operator.
 

Detailed Description

template<class K, class I, class H = DefHashFunc<K>>
class ogdf::HashConstIterator< K, I, H >

Iterators for hash tables.

This class implements an iterator for iterating over all elements in a hash table. Hash iterators are provided by Hashing<K,I>::begin().

Example

The following code snippet demonstrates how to iterate over all elements of a hash table. First, the example fills a hash table with a tiny German–English dictionary, and then it iterates over the elements and prints the entries.

H.fastInsert("Hund","dog");
H.fastInsert("Katze","cat");
H.fastInsert("Maus","mouse");
for(it = H.begin(); it.valid(); ++it)
std::cout << it.key() << " -> " << it.info() << std::endl;
Iterators for hash tables.
Definition Hashing.h:429
bool valid() const
Returns true if the hash iterator points to an element.
Definition Hashing.h:456
const K & key() const
Returns the key of the hash element pointed to.
Definition Hashing.h:459
const I & info() const
Returns the information of the hash element pointed to.
Definition Hashing.h:462
Hashing with chaining and table doubling.
Definition Hashing.h:261
HashElement< K, I > * fastInsert(const K &key, const I &info)
Inserts a new element with key key and information info into the hash table.
Definition Hashing.h:348

Definition at line 429 of file Hashing.h.

Constructor & Destructor Documentation

◆ HashConstIterator() [1/3]

template<class K , class I , class H = DefHashFunc<K>>
ogdf::HashConstIterator< K, I, H >::HashConstIterator ( )
inline

Creates a hash iterator pointing to no element.

Definition at line 436 of file Hashing.h.

◆ HashConstIterator() [2/3]

template<class K , class I , class H = DefHashFunc<K>>
ogdf::HashConstIterator< K, I, H >::HashConstIterator ( HashElement< K, I > *  pElement,
HashElement< K, I > **  pList,
const Hashing< K, I, H > *  pHashing 
)
inline

Creates a hash iterator pointing to element pElement in list pList of hash table pHashing.

Definition at line 439 of file Hashing.h.

◆ HashConstIterator() [3/3]

template<class K , class I , class H = DefHashFunc<K>>
ogdf::HashConstIterator< K, I, H >::HashConstIterator ( const HashConstIterator< K, I, H > &  it)
inline

Copy constructor.

Definition at line 444 of file Hashing.h.

Member Function Documentation

◆ info()

template<class K , class I , class H = DefHashFunc<K>>
const I & ogdf::HashConstIterator< K, I, H >::info ( ) const
inline

Returns the information of the hash element pointed to.

Definition at line 462 of file Hashing.h.

◆ key()

template<class K , class I , class H = DefHashFunc<K>>
const K & ogdf::HashConstIterator< K, I, H >::key ( ) const
inline

Returns the key of the hash element pointed to.

Definition at line 459 of file Hashing.h.

◆ operator++()

template<class K , class I , class H = DefHashFunc<K>>
HashConstIterator< K, I, H > & ogdf::HashConstIterator< K, I, H >::operator++ ( )
inline

Moves this hash iterator to the next element (iterator gets invalid if no more elements).

Definition at line 477 of file Hashing.h.

◆ operator=()

template<class K , class I , class H = DefHashFunc<K>>
HashConstIterator & ogdf::HashConstIterator< K, I, H >::operator= ( const HashConstIterator< K, I, H > &  it)
inline

Assignment operator.

Definition at line 448 of file Hashing.h.

◆ valid()

template<class K , class I , class H = DefHashFunc<K>>
bool ogdf::HashConstIterator< K, I, H >::valid ( ) const
inline

Returns true if the hash iterator points to an element.

Definition at line 456 of file Hashing.h.

Friends And Related Symbol Documentation

◆ operator!=

template<class K , class I , class H = DefHashFunc<K>>
bool operator!= ( const HashConstIterator< K, I, H > &  it1,
const HashConstIterator< K, I, H > &  it2 
)
friend

Inequality operator.

Definition at line 471 of file Hashing.h.

◆ operator==

template<class K , class I , class H = DefHashFunc<K>>
bool operator== ( const HashConstIterator< K, I, H > &  it1,
const HashConstIterator< K, I, H > &  it2 
)
friend

Equality operator.

Definition at line 465 of file Hashing.h.

Member Data Documentation

◆ m_pElement

template<class K , class I , class H = DefHashFunc<K>>
HashElement<K, I>* ogdf::HashConstIterator< K, I, H >::m_pElement
private

The hash element to which the iterator points.

Definition at line 430 of file Hashing.h.

◆ m_pHashing

template<class K , class I , class H = DefHashFunc<K>>
const Hashing<K, I, H>* ogdf::HashConstIterator< K, I, H >::m_pHashing
private

The associated hash table.

Definition at line 432 of file Hashing.h.

◆ m_pList

template<class K , class I , class H = DefHashFunc<K>>
HashElement<K, I>** ogdf::HashConstIterator< K, I, H >::m_pList
private

The list containg the hash element.

Definition at line 431 of file Hashing.h.


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