Flow 2.0.0
Flow project: Full implementation reference.
Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Attributes | List of all members
flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR > Class Template Reference

The internal-use key/iterator-wrapper, used as the key type in internal-use set-type Linked_hash_key_set. More...

#include <linked_hash.hpp>

Collaboration diagram for flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >:
[legend]

Public Types

using Key = Key_t
 Convenience alias for template arg. More...
 
using Iterator = Iterator_t
 Convenience alias for template arg. More...
 

Public Member Functions

 Linked_hash_key (const Key &key)
 Constructs *this to contain a pointer to a Key living outside the *this-using data structure Linked_hash_key_set (presumably as arg to its .find()). More...
 
 Linked_hash_key (const Iterator &it)
 Constructs *this to contain an Iterator into the *this-using data structure Linked_hash_key_set (presumably as arg to its .insert()). More...
 
const Keykey () const
 Returns reference to immutable key to which we saved a pointer via one of our constructor forms. More...
 
Iterator iter () const
 Assuming we were as-if constructed via the ctor that takes an Iterator (as opposed to a Key reference), returns copy of the stored iterator. More...
 

Static Public Attributes

static constexpr bool S_IS_ITER_TO_PAIR = IS_ITER_TO_PAIR
 Convenience alias for template arg. More...
 

Private Types

using Key_ptr = Key const *
 Short-hand for raw pointer to an immutable Key living outside the *this-using data structure. More...
 

Private Attributes

std::variant< Key_ptr, Iteratorm_key_hndl
 Stores the key, without copying its actual value, as either a pointer to an immutable key, or as an iterator into a structure such that it contains the key. More...
 

Detailed Description

template<typename Key_t, typename Iterator_t, bool IS_ITER_TO_PAIR>
class flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >

The internal-use key/iterator-wrapper, used as the key type in internal-use set-type Linked_hash_key_set.

For background please see Linked_hash_map doc header Impl section, and where that points. Note that the same information applies to Linked_hash_set as well. (IS_ITER_TO_PAIR indicates which guy this is helping implement.)

That said, we very specifically just need to:

Template Parameters
Key_tSee Linked_hash_map, Linked_hash_set.
Iterator_tLinked_hash_map::Iterator or Linked_hash_set::Iterator.
IS_ITER_TO_PAIRtrue for Linked_hash_map, false for Linked_hash_set.

Definition at line 52 of file linked_hash.hpp.

Member Typedef Documentation

◆ Iterator

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
using flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::Iterator = Iterator_t

Convenience alias for template arg.

Definition at line 61 of file linked_hash.hpp.

◆ Key

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
using flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::Key = Key_t

Convenience alias for template arg.

Definition at line 58 of file linked_hash.hpp.

◆ Key_ptr

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
using flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::Key_ptr = Key const *
private

Short-hand for raw pointer to an immutable Key living outside the *this-using data structure.

Definition at line 120 of file linked_hash.hpp.

Constructor & Destructor Documentation

◆ Linked_hash_key() [1/2]

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::Linked_hash_key ( const Key key)

Constructs *this to contain a pointer to a Key living outside the *this-using data structure Linked_hash_key_set (presumably as arg to its .find()).

Parameters
keyThe key to which to point. The referred object must continue to be valid, until either *this is destroyed, or via assignment *this changes value.

Definition at line 223 of file linked_hash.hpp.

◆ Linked_hash_key() [2/2]

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::Linked_hash_key ( const Iterator it)

Constructs *this to contain an Iterator into the *this-using data structure Linked_hash_key_set (presumably as arg to its .insert()).

Parameters
itThe iterator a copy of which to store. The pointee of the iterator must not be erased or moved in an iterator-invalidating fashion, until either *this is destroyed, or via assignment *this changes value.

Definition at line 230 of file linked_hash.hpp.

Member Function Documentation

◆ iter()

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
Iterator_t flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::iter

Assuming we were as-if constructed via the ctor that takes an Iterator (as opposed to a Key reference), returns copy of the stored iterator.

Behavior undefined if the assumption does not hold (as of this writing exception is thrown).

Informally: if this->key() was found in the Linked_hash_key_set, then this accessor may be used; else it may not. That *this-using data structure – a hash-set – shall use Linked_hash_key_hash and Linked_hash_key_pred for its hasher and equality functors respectively.

Returns
See above.

Definition at line 261 of file linked_hash.hpp.

◆ key()

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
const Key_t & flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::key

Returns reference to immutable key to which we saved a pointer via one of our constructor forms.

Specifically, then, that's either simply the ctor-saved pointer (in reference form); or the address of the key stored as stored within the *this-using data structure Linked_hash_key_set.

Returns
See above.

Definition at line 238 of file linked_hash.hpp.

Member Data Documentation

◆ m_key_hndl

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
std::variant<Key_ptr, Iterator> flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::m_key_hndl
private

Stores the key, without copying its actual value, as either a pointer to an immutable key, or as an iterator into a structure such that it contains the key.

In the latter case:

Definition at line 131 of file linked_hash.hpp.

◆ S_IS_ITER_TO_PAIR

template<typename Key_t , typename Iterator_t , bool IS_ITER_TO_PAIR>
constexpr bool flow::util::Linked_hash_key< Key_t, Iterator_t, IS_ITER_TO_PAIR >::S_IS_ITER_TO_PAIR = IS_ITER_TO_PAIR
staticconstexpr

Convenience alias for template arg.

Definition at line 66 of file linked_hash.hpp.


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