HashTable< T, Key, Hash >::Iterator< Const > Class Template Reference

Internally used base for iterator and const_iterator. More...

Inheritance diagram for HashTable< T, Key, Hash >::Iterator< Const >:
[legend]

Public Types

using iterator_category = std::forward_iterator_tag
 
using difference_type = this_type::difference_type
 
using table_type = typename std::conditional< Const, const this_type, this_type >::type
 The HashTable container type. More...
 
using node_type = typename std::conditional< Const, const this_type::node_type, this_type::node_type >::type
 The node-type being addressed. More...
 
using key_type = this_type::key_type
 The key type. More...
 
using mapped_type = typename std::conditional< Const, const this_type::mapped_type, this_type::mapped_type >::type
 The object type being addressed. More...
 

Public Member Functions

bool good () const noexcept
 True if iterator points to an entry. More...
 
bool found () const noexcept
 True if iterator points to an entry - same as good() More...
 
const Key & key () const
 The key associated with the iterator. More...
 
Ostreamprint (Ostream &os) const
 Write the (key, val) pair. More...
 
 operator bool () const noexcept
 True if iterator points to an entry. More...
 
template<bool Any>
bool operator== (const Iterator< Any > &iter) const noexcept
 Compare hash-entry element pointers. More...
 
template<bool Any>
bool operator!= (const Iterator< Any > &iter) const noexcept
 

Protected Member Functions

constexpr Iterator () noexcept
 Default construct (end iterator) More...
 
 Iterator (table_type *tbl)
 Construct from begin of hash-table. More...
 
 Iterator (table_type *tbl, const Key &key)
 Construct by finding key in hash table. More...
 
void increment ()
 Increment to the next position. More...
 
template<bool Any>
 operator const Iterator< Any > & () const
 Permit explicit cast to the other (const/non-const) iterator. More...
 

Protected Attributes

node_typeentry_
 The selected entry. More...
 
table_typecontainer_
 The hash-table container being iterated on. More...
 
label index_
 Index within the hash-table data. More...
 

Friends

class HashTable
 

Detailed Description

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
class Foam::HashTable< T, Key, Hash >::Iterator< Const >

Internally used base for iterator and const_iterator.

The iterator base for HashTable (internal use only).

Note: data and functions are protected, to allow reuse by iterator and prevent most external usage. iterator and const_iterator have the same size, allowing us to reinterpret_cast between them (if desired)

Definition at line 596 of file HashTable.H.

Member Typedef Documentation

◆ iterator_category

using iterator_category = std::forward_iterator_tag

Definition at line 601 of file HashTable.H.

◆ difference_type

Definition at line 602 of file HashTable.H.

◆ table_type

using table_type = typename std::conditional < Const, const this_type, this_type >::type

The HashTable container type.

Definition at line 605 of file HashTable.H.

◆ node_type

using node_type = typename std::conditional < Const, const this_type::node_type, this_type::node_type >::type

The node-type being addressed.

Definition at line 613 of file HashTable.H.

◆ key_type

The key type.

Definition at line 621 of file HashTable.H.

◆ mapped_type

using mapped_type = typename std::conditional < Const, const this_type::mapped_type, this_type::mapped_type >::type

The object type being addressed.

Definition at line 624 of file HashTable.H.

Constructor & Destructor Documentation

◆ Iterator() [1/3]

constexpr Iterator
inlineconstexprprotectednoexcept

Default construct (end iterator)

Definition at line 33 of file HashTableIterI.H.

◆ Iterator() [2/3]

◆ Iterator() [3/3]

Iterator ( table_type tbl,
const Key &  key 
)
protected

Construct by finding key in hash table.

Definition at line 32 of file HashTableIter.C.

References HashTable< T, Key, Hash >::Iterator< Const >::container_, HashTable< T, Key, Hash >::Iterator< Const >::entry_, HashTable< T, Key, Hash >::Iterator< Const >::index_, and HashTable< T, Key, Hash >::Iterator< Const >::key().

Here is the call graph for this function:

Member Function Documentation

◆ good()

bool good
inlinenoexcept

True if iterator points to an entry.

This can be used directly instead of comparing to end()

Definition at line 115 of file HashTableIterI.H.

Referenced by HashTable< T, Key, Hash >::at(), HashTable< T, Key, Hash >::found(), HashTable< T, Key, Hash >::lookup(), HashTable< T, Key, Hash >::operator()(), and HashTable< T, Key, Hash >::operator==().

Here is the caller graph for this function:

◆ found()

bool found
inlinenoexcept

True if iterator points to an entry - same as good()

Definition at line 124 of file HashTableIterI.H.

Referenced by IOobjectList::cfindObject(), cellTable::name(), and cellTable::setName().

Here is the caller graph for this function:

◆ key()

const Key & key
inline

The key associated with the iterator.

Definition at line 132 of file HashTableIterI.H.

Referenced by HashTable< T, Key, Hash >::Iterator< Const >::Iterator(), ensightCells::writeDict(), and ensightFaces::writeDict().

Here is the caller graph for this function:

◆ print()

Foam::Ostream & print ( Ostream os) const
inline

Write the (key, val) pair.

Definition at line 140 of file HashTableIterI.H.

References os().

Here is the call graph for this function:

◆ operator bool()

operator bool
inlineexplicitnoexcept

True if iterator points to an entry.

This can be used directly instead of comparing to end()

Definition at line 155 of file HashTableIterI.H.

◆ operator==()

bool operator== ( const Iterator< Any > &  iter) const
inlinenoexcept

Compare hash-entry element pointers.

Independent of const/non-const access

Definition at line 165 of file HashTableIterI.H.

◆ operator!=()

bool operator!= ( const Iterator< Any > &  iter) const
inlinenoexcept

Definition at line 177 of file HashTableIterI.H.

◆ increment()

void increment
inlineprotected

Increment to the next position.

Definition at line 78 of file HashTableIterI.H.

◆ operator const Iterator< Any > &()

operator const Iterator< Any > & ( ) const
inlineexplicitprotected

Permit explicit cast to the other (const/non-const) iterator.

Definition at line 702 of file HashTable.H.

Friends And Related Function Documentation

◆ HashTable

friend class HashTable
friend

Definition at line 664 of file HashTable.H.

Member Data Documentation

◆ entry_

node_type* entry_
protected

The selected entry.

MUST be the first member for easy comparison between iterators and to support reinterpret_cast from nullObject

Definition at line 671 of file HashTable.H.

Referenced by HashTable< T, Key, Hash >::erase(), and HashTable< T, Key, Hash >::Iterator< Const >::Iterator().

◆ container_

table_type* container_
protected

The hash-table container being iterated on.

Uses pointer for default copy/assignment

Definition at line 675 of file HashTable.H.

Referenced by HashTable< T, Key, Hash >::Iterator< Const >::Iterator().

◆ index_

label index_
protected

Index within the hash-table data.

A signed value, since iterator_erase() needs a negative value to mark the position.

Definition at line 680 of file HashTable.H.

Referenced by HashTable< T, Key, Hash >::erase(), and HashTable< T, Key, Hash >::Iterator< Const >::Iterator().


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