Loading...
Searching...
No Matches
HashTable< T, Key, Hash >::Iterator< Const > Class Template Reference

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

#include <HashTable.H>

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

Public Types

using iterator_category = std::forward_iterator_tag
using difference_type = this_type::difference_type
using table_type
 The HashTable container type.
using node_type
 The node-type being addressed.
using key_type = this_type::key_type
 The key type.
using mapped_type
 The object type being addressed.

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

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 871 of file HashTable.H.

Member Typedef Documentation

◆ iterator_category

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
using iterator_category = std::forward_iterator_tag

Definition at line 876 of file HashTable.H.

◆ difference_type

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
using difference_type = this_type::difference_type

Definition at line 877 of file HashTable.H.

◆ table_type

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
using table_type
Initial value:
std::conditional_t
<
Const,
const this_type,
>
HashTable< T, Key, Hash > this_type
The template instance used for this HashTable.
Definition HashTable.H:132

The HashTable container type.

Definition at line 882 of file HashTable.H.

◆ node_type

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
using node_type
Initial value:
std::conditional_t
<
Const,
>
std::conditional_t< std::is_same_v< Foam::zero, std::remove_cv_t< T > >, Detail::HashTableSingle< Key >, Detail::HashTablePair< Key, T > > node_type
Definition HashTable.H:138

The node-type being addressed.

Definition at line 892 of file HashTable.H.

◆ key_type

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
using key_type = this_type::key_type

The key type.

Definition at line 902 of file HashTable.H.

◆ mapped_type

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
using mapped_type
Initial value:

The object type being addressed.

Definition at line 907 of file HashTable.H.

Constructor & Destructor Documentation

◆ Iterator() [1/3]

template<class T, class Key, class Hash>
template<bool Const>
Iterator ( )
inlineconstexprprotectednoexcept

Default construct. Also the same as the end iterator.

Definition at line 26 of file HashTableIterI.H.

References container_, entry_, index_, Iterator(), and Foam::noexcept.

Referenced by HashTable, Iterator(), Iterator(), Iterator(), operator const Iterator< Any > &(), operator!=(), and operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Iterator() [2/3]

template<class T, class Key, class Hash>
template<bool Const>
Iterator ( table_type * tbl)
inlineexplicitprotected

Construct from begin of hash-table.

Definition at line 36 of file HashTableIterI.H.

References container_, entry_, if(), index_, and Iterator().

Here is the call graph for this function:

◆ Iterator() [3/3]

template<class T, class Key, class Hash>
template<bool Const>
Iterator ( table_type * tbl,
const Key & key )
protected

Construct by finding key in hash table.

Definition at line 25 of file HashTableIter.C.

References container_, entry_, index_, Iterator(), and key().

Here is the call graph for this function:

Member Function Documentation

◆ increment()

template<class T, class Key, class Hash>
template<bool Const>
void increment ( )
inlineprotected

Increment to the next position.

Definition at line 72 of file HashTableIterI.H.

References container_, entry_, increment(), and index_.

Referenced by HashTable, and increment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator const Iterator< Any > &()

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
template<bool Any>
operator const Iterator< Any > & ( ) const
inlineexplicitprotected

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

Definition at line 975 of file HashTable.H.

References Iterator(), and HashTable< T, Key, Hash >::operator.

Here is the call graph for this function:

◆ good()

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
bool good ( ) const
inlinenoexcept

True if iterator points to an entry.

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

Definition at line 990 of file HashTable.H.

References entry_, and Foam::noexcept.

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

Here is the caller graph for this function:

◆ found()

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
bool found ( ) const
inlinenoexcept

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

Definition at line 995 of file HashTable.H.

References entry_, and Foam::noexcept.

◆ key()

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
const Key & key ( ) const
inline

◆ print()

template<class T, class Key, class Hash>
template<bool Const>
Foam::Ostream & print ( Ostream & os) const
inline

Write the (key, val) pair.

Definition at line 108 of file HashTableIterI.H.

References entry_, os(), and print().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator bool()

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
operator bool ( ) const
inlineexplicitnoexcept

True if iterator points to an entry.

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

Definition at line 1015 of file HashTable.H.

References entry_, and Foam::noexcept.

◆ operator==()

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
template<bool Any>
bool operator== ( const Iterator< Any > & iter) const
inlinenoexcept

Compare hash-entry element pointers.

Independent of const/non-const access

Definition at line 1023 of file HashTable.H.

References entry_, and Iterator().

Here is the call graph for this function:

◆ operator!=()

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
template<bool Any>
bool operator!= ( const Iterator< Any > & iter) const
inlinenoexcept

Definition at line 1029 of file HashTable.H.

References entry_, and Iterator().

Here is the call graph for this function:

◆ HashTable

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

Definition at line 943 of file HashTable.H.

References HashTable, increment(), Iterator(), key(), and Foam::noexcept.

Referenced by HashTable.

Member Data Documentation

◆ entry_

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
node_type* entry_
protected

◆ container_

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
table_type* container_
protected

The hash-table container being iterated on.

Uses pointer for default copy/assignment

Definition at line 932 of file HashTable.H.

Referenced by increment(), Iterator(), Iterator(), and Iterator().

◆ index_

template<class T, class Key = word, class Hash = Foam::Hash<Key>>
template<bool Const>
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 940 of file HashTable.H.

Referenced by increment(), Iterator(), Iterator(), and Iterator().


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