Flow 2.0.0
Flow project: Full implementation reference.
Public Types | Public Member Functions | Private Types | Private Attributes | Related Functions | List of all members
flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t > Class Template Reference

An object of this class is a map that combines the lookup speed of an unordered_set<> and ordering and iterator stability capabilities of a list<>. More...

#include <linked_hash_set.hpp>

Collaboration diagram for flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >:
[legend]

Public Types

using Key = Key_t
 Convenience alias for template arg. More...
 
using Hash = Hash_t
 Convenience alias for template arg. More...
 
using Pred = Pred_t
 Convenience alias for template arg. More...
 
using Value = Key
 Short-hand for values, which in this case are simply the keys. More...
 
using size_type = std::size_t
 Expresses sizes/lengths of relevant things. More...
 
using difference_type = std::ptrdiff_t
 Type for difference of size_types. More...
 
using Const_iterator = typename Value_list::const_iterator
 Type for iterator pointing into an immutable structure of this type. More...
 
using Iterator = Const_iterator
 Type for iterator pointing into a mutable structure of this type but actually that is not possible; so alias to Const_iterator. More...
 
using Const_reverse_iterator = typename Value_list::const_reverse_iterator
 Type for reverse iterator pointing into an immutable structure of this type. More...
 
using Reverse_iterator = Const_reverse_iterator
 Type for reverse iterator pointing into a mutable structure of this type but actually that is not possible; so alias to Const_reverse_iterator. More...
 
using key_type = Key
 For container compliance (hence the irregular capitalization): Key type. More...
 
using value_type = Value
 For container compliance (hence the irregular capitalization): Value type. More...
 
using hasher = Hash
 For container compliance (hence the irregular capitalization): Hash type. More...
 
using key_equal = Pred
 For container compliance (hence the irregular capitalization): Pred type. More...
 
using pointer = Value *
 For container compliance (hence the irregular capitalization): pointer to Key type. More...
 
using const_pointer = const Value *
 For container compliance (hence the irregular capitalization): pointer to const Key type. More...
 
using reference = Value &
 For container compliance (hence the irregular capitalization): reference to Key type. More...
 
using const_reference = const Value &
 For container compliance (hence the irregular capitalization): reference to const Key type. More...
 
using iterator = Iterator
 For container compliance (hence the irregular capitalization): Iterator type. More...
 
using const_iterator = Const_iterator
 For container compliance (hence the irregular capitalization): Const_iterator type. More...
 

Public Member Functions

 Linked_hash_set (size_type n_buckets=size_type(-1), const Hash &hasher_obj=Hash{}, const Pred &pred=Pred{})
 Constructs empty structure with some basic parameters. More...
 
 Linked_hash_set (std::initializer_list< Value > values, size_type n_buckets=size_type(-1), const Hash &hasher_obj=Hash{}, const Pred &pred=Pred{})
 Constructs structure with some basic parameters, and values initialized from initializer list. More...
 
 Linked_hash_set (const Linked_hash_set &src)
 Constructs object that is a copy of the given source. More...
 
 Linked_hash_set (Linked_hash_set &&src)
 Constructs object by making it equal to the given source, while the given source becomes as-if default-cted. More...
 
Linked_hash_setoperator= (const Linked_hash_set &src)
 Overwrites this object with a copy of the given source. More...
 
Linked_hash_setoperator= (Linked_hash_set &&src)
 Overwrites this object making it identical to the given source, while the given source becomes as-if default-cted. More...
 
void swap (Linked_hash_set &other)
 Swaps the contents of this structure and other. More...
 
std::pair< Iterator, boolinsert (const Key &key)
 Attempts to insert (copying it) the given keyinto the map; if key already in *this makes no change. More...
 
std::pair< Iterator, boolinsert (Key &&key)
 Identical to the other overload, except that (if key not already present in *this) the key is moved, not copied, into *this. More...
 
Const_iterator find (const Key &key) const
 Attempts to find value at the given key in the map. More...
 
size_type count (const Key &key) const
 Returns the number of times a key equal to the given one is present (as-if via find()) in the map: either 1 or 0. More...
 
void touch (const Const_iterator &it)
 Given a valid iterator into the structure, makes the pointed-to element "newest" by moving it from wherever it is to be first in the iteration order. More...
 
bool touch (const Key &key)
 Given a key into the structure, makes the corresponding element "newest" by moving it from wherever it is to be first in the iteration order; or does nothing if no such key. More...
 
Const_iterator erase (const Const_iterator &it)
 Erases the element pointed to by the given valid iterator. More...
 
Const_iterator erase (const Const_iterator &it_newest, const Const_iterator &it_past_oldest)
 Erases all elements in the range [it_newest, it_past_oldest). More...
 
size_type erase (const Key &key)
 Erases the element with the given key, if it exists. More...
 
void clear ()
 Makes it so that size() == 0. More...
 
Iterator begin () const
 Synonym of newest(). More...
 
Iterator newest () const
 Returns first, a/k/a "newest," element's iterator (to immutable element, due to nature of this type). More...
 
Iterator end () const
 Synonym of past_oldest(). More...
 
Iterator past_oldest () const
 Returns one past last, a/k/a "oldest," element's iterator (to immutable element, due to nature of this type). More...
 
Const_iterator cbegin () const
 Synonym of const_newest(). More...
 
Const_iterator const_newest () const
 Returns first, a/k/a "newest," element's iterator (to immutable element). More...
 
Const_iterator cend () const
 Synonym of const_past_oldest(). More...
 
Const_iterator const_past_oldest () const
 Returns one past last, a/k/a "oldest," element's iterator (to immutable element). More...
 
Reverse_iterator rbegin () const
 Synonym of oldest(). More...
 
Reverse_iterator oldest () const
 Returns first, a/k/a "oldest," element's reverse iterator (to immutable element, due to nature of this type). More...
 
Reverse_iterator rend () const
 Synonym of past_newest(). More...
 
Reverse_iterator past_newest () const
 Returns one past last, a/k/a "newest," element's reverse iterator (to immutable element, due to nature of this type). More...
 
Const_reverse_iterator crbegin () const
 Synonym of const_oldest(). More...
 
Const_reverse_iterator const_oldest () const
 Returns first, a/k/a "oldest," element's reverse iterator (to immutable element). More...
 
Const_reverse_iterator crend () const
 Synonym of const_past_newest(). More...
 
Const_reverse_iterator const_past_newest () const
 Returns one past last, a/k/a "newest," element's reverse iterator (to immutable element). More...
 
bool empty () const
 Returns true if and only if container is empty. More...
 
size_type size () const
 Returns number of elements stored. More...
 
size_type max_size () const
 Returns max number of elements that can be stored. More...
 

Private Types

using Value_list = std::list< Value >
 Short-hand for doubly linked list of Keys. More...
 

Private Attributes

Value_list m_value_list
 Analogous to Linked_hash_map::m_value_list; but simpler in that it just stores Keys, not pairs of (stuff). More...
 
Linked_hash_key_set< Key, Iterator, Hash, Pred, false > m_value_iter_set
 Analogous to Linked_hash_map::m_value_iter_set; just configured to generate a simpler .iter() off each element by supplying false instead of true for the last template arg. More...
 

Related Functions

(Note that these are not member functions.)

template<typename Key_t , typename Hash_t , typename Pred_t >
void swap (Linked_hash_set< Key_t, Hash_t, Pred_t > &val1, Linked_hash_set< Key_t, Hash_t, Pred_t > &val2)
 Equivalent to val1.swap(val2). More...
 

Detailed Description

template<typename Key_t, typename Hash_t, typename Pred_t>
class flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >

An object of this class is a map that combines the lookup speed of an unordered_set<> and ordering and iterator stability capabilities of a list<>.

This is just like Linked_hash_map, except it only stores keys – no mapped values. All comments, except for self-explanatory differences, from Linked_hash_map apply here. Thus I will only speak of differences below to avoid duplication of this header. Incidentally the most visible API difference (aside from having no Mappeds to speak of, only Keys) is that Linked_hash_set lacks (*this)[] operator; so one always uses insert() to insert.

Move semantics for keys are supported (let x be a *this):

The iterators are, really, list<Key> const-iterators; and as such are not invalidated except due to direct erasure of a given pointee.

Impl notes

It's very much like Linked_hash_map; just the list m_value_list stores only Keys as opposed to pair<const Key, Mapped>s. See Linked_hash_map.

Template Parameters
Key_tKey type. Same as for Linked_hash_map.
Hash_tHasher type. Same as for Linked_hash_map.
Pred_tEquality functor type. Same as for Linked_hash_map.

Definition at line 59 of file linked_hash_set.hpp.

Member Typedef Documentation

◆ Const_iterator

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_iterator = typename Value_list::const_iterator

Type for iterator pointing into an immutable structure of this type.

Definition at line 92 of file linked_hash_set.hpp.

◆ const_iterator

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::const_iterator = Const_iterator

For container compliance (hence the irregular capitalization): Const_iterator type.

Definition at line 128 of file linked_hash_set.hpp.

◆ const_pointer

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::const_pointer = const Value*

For container compliance (hence the irregular capitalization): pointer to const Key type.

Definition at line 120 of file linked_hash_set.hpp.

◆ const_reference

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::const_reference = const Value&

For container compliance (hence the irregular capitalization): reference to const Key type.

Definition at line 124 of file linked_hash_set.hpp.

◆ Const_reverse_iterator

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_reverse_iterator = typename Value_list::const_reverse_iterator

Type for reverse iterator pointing into an immutable structure of this type.

Definition at line 101 of file linked_hash_set.hpp.

◆ difference_type

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::difference_type = std::ptrdiff_t

Type for difference of size_types.

Definition at line 89 of file linked_hash_set.hpp.

◆ Hash

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Hash = Hash_t

Convenience alias for template arg.

Definition at line 68 of file linked_hash_set.hpp.

◆ hasher

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::hasher = Hash

For container compliance (hence the irregular capitalization): Hash type.

Definition at line 114 of file linked_hash_set.hpp.

◆ Iterator

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator = Const_iterator

Type for iterator pointing into a mutable structure of this type but actually that is not possible; so alias to Const_iterator.

Note these are standard semantics (see std::set, etc.).

Definition at line 98 of file linked_hash_set.hpp.

◆ iterator

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::iterator = Iterator

For container compliance (hence the irregular capitalization): Iterator type.

Definition at line 126 of file linked_hash_set.hpp.

◆ Key

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Key = Key_t

Convenience alias for template arg.

Definition at line 65 of file linked_hash_set.hpp.

◆ key_equal

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::key_equal = Pred

For container compliance (hence the irregular capitalization): Pred type.

Definition at line 116 of file linked_hash_set.hpp.

◆ key_type

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::key_type = Key

For container compliance (hence the irregular capitalization): Key type.

Definition at line 110 of file linked_hash_set.hpp.

◆ pointer

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::pointer = Value*

For container compliance (hence the irregular capitalization): pointer to Key type.

Definition at line 118 of file linked_hash_set.hpp.

◆ Pred

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Pred = Pred_t

Convenience alias for template arg.

Definition at line 71 of file linked_hash_set.hpp.

◆ reference

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::reference = Value&

For container compliance (hence the irregular capitalization): reference to Key type.

Definition at line 122 of file linked_hash_set.hpp.

◆ Reverse_iterator

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Reverse_iterator = Const_reverse_iterator

Type for reverse iterator pointing into a mutable structure of this type but actually that is not possible; so alias to Const_reverse_iterator.

Note these are standard semantics (see std::set, etc.).

Definition at line 107 of file linked_hash_set.hpp.

◆ size_type

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::size_type = std::size_t

Expresses sizes/lengths of relevant things.

Definition at line 87 of file linked_hash_set.hpp.

◆ Value

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Value = Key

Short-hand for values, which in this case are simply the keys.

Definition at line 74 of file linked_hash_set.hpp.

◆ Value_list

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Value_list = std::list<Value>
private

Short-hand for doubly linked list of Keys.

Definition at line 80 of file linked_hash_set.hpp.

◆ value_type

template<typename Key_t , typename Hash_t , typename Pred_t >
using flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::value_type = Value

For container compliance (hence the irregular capitalization): Value type.

Definition at line 112 of file linked_hash_set.hpp.

Constructor & Destructor Documentation

◆ Linked_hash_set() [1/4]

template<typename Key_t , typename Hash_t , typename Pred_t >
flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Linked_hash_set ( size_type  n_buckets = size_type(-1),
const Hash hasher_obj = Hash{},
const Pred pred = Pred{} 
)

Constructs empty structure with some basic parameters.

Parameters
n_bucketsNumber of buckets for the unordered (hash) table. Special value -1 (default) will cause us to use whatever unordered_set<> would use by default.
hasher_objInstance of the hash function type (hasher_obj(k) -> size_t should be hash of Key k).
predInstance of the equality function type (pred(k1, k2) should return true if and only if the Keys are equal by value).

Definition at line 470 of file linked_hash_set.hpp.

◆ Linked_hash_set() [2/4]

template<typename Key_t , typename Hash_t , typename Pred_t >
flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Linked_hash_set ( std::initializer_list< Value values,
size_type  n_buckets = size_type(-1),
const Hash hasher_obj = Hash{},
const Pred pred = Pred{} 
)
explicit

Constructs structure with some basic parameters, and values initialized from initializer list.

The values are inserted as if insert(v) was called for each element v in values in reverse order. Since the canonical ordering places the newest (last inserted/touch()ed) element at the front of the ordering, that means that forward iteration through the set (right after this constructor runs) will yield values in the same order as in initializer list values.

Parameters
valuesValues with which to fill the structure after initializing it. Typically you'd provide a series of keys like this: { key1, key2, ... }. They will appear in iterated sequence in the same order as they appear in this list.
n_bucketsSee other constructor.
hasher_objSee other constructor.
predSee other constructor.

Definition at line 479 of file linked_hash_set.hpp.

References flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::m_value_iter_set, and flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::m_value_list.

◆ Linked_hash_set() [3/4]

template<typename Key_t , typename Hash_t , typename Pred_t >
flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Linked_hash_set ( const Linked_hash_set< Key_t, Hash_t, Pred_t > &  src)

Constructs object that is a copy of the given source.

Equivalent to default-ction followed by operator=(src).

Parameters
srcSource object.

Definition at line 502 of file linked_hash_set.hpp.

◆ Linked_hash_set() [4/4]

template<typename Key_t , typename Hash_t , typename Pred_t >
flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Linked_hash_set ( Linked_hash_set< Key_t, Hash_t, Pred_t > &&  src)

Constructs object by making it equal to the given source, while the given source becomes as-if default-cted.

Equivalent to default-ction followed by operator=(std::move(src)).

This is a constant-time operation.

Parameters
srcSource object which is emptied.

Definition at line 509 of file linked_hash_set.hpp.

Member Function Documentation

◆ begin()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::begin

Synonym of newest().

Returns
See newest().

Definition at line 712 of file linked_hash_set.hpp.

◆ cbegin()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::cbegin

Synonym of const_newest().

Exists as standard container method (hence the odd formatting).

Returns
See const_newest().

Definition at line 719 of file linked_hash_set.hpp.

◆ cend()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::cend

Synonym of const_past_oldest().

Exists as standard container method (hence the odd formatting).

Returns
See const_past_oldest().

Definition at line 747 of file linked_hash_set.hpp.

◆ clear()

template<typename Key_t , typename Hash_t , typename Pred_t >
void flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::clear

Makes it so that size() == 0.

Definition at line 690 of file linked_hash_set.hpp.

Referenced by flow::net_flow::Event_set::clear_result_sockets(), flow::net_flow::Event_set::clear_wanted_sockets(), and flow::net_flow::Event_set::emit_result_sockets().

Here is the caller graph for this function:

◆ const_newest()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::const_newest

Returns first, a/k/a "newest," element's iterator (to immutable element).

Returns
Ditto.

Definition at line 705 of file linked_hash_set.hpp.

◆ const_oldest()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_reverse_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::const_oldest

Returns first, a/k/a "oldest," element's reverse iterator (to immutable element).

Returns
Ditto.

Definition at line 761 of file linked_hash_set.hpp.

◆ const_past_newest()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_reverse_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::const_past_newest

Returns one past last, a/k/a "newest," element's reverse iterator (to immutable element).

Returns
Ditto.

Definition at line 789 of file linked_hash_set.hpp.

◆ const_past_oldest()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::const_past_oldest

Returns one past last, a/k/a "oldest," element's iterator (to immutable element).

Returns
Ditto.

Definition at line 733 of file linked_hash_set.hpp.

◆ count()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::size_type flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::count ( const Key key) const

Returns the number of times a key equal to the given one is present (as-if via find()) in the map: either 1 or 0.

Parameters
keyKey whose equal to find.
Returns
0 or 1.

Definition at line 626 of file linked_hash_set.hpp.

◆ crbegin()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_reverse_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::crbegin

Synonym of const_oldest().

Returns
See const_oldest().

Definition at line 775 of file linked_hash_set.hpp.

◆ crend()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_reverse_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::crend

Synonym of const_past_newest().

Exists as standard container method.

Returns
See const_past_newest().

Definition at line 803 of file linked_hash_set.hpp.

◆ empty()

template<typename Key_t , typename Hash_t , typename Pred_t >
bool flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::empty

Returns true if and only if container is empty.

Same performance as of unordered_set<>.

Returns
Ditto.

Definition at line 816 of file linked_hash_set.hpp.

Referenced by flow::net_flow::Node::event_set_all_check_delta(), and flow::net_flow::Node::event_set_check_baseline().

Here is the caller graph for this function:

◆ end()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::end

Synonym of past_oldest().

Exists as standard container method.

Returns
See past_oldest().

Definition at line 740 of file linked_hash_set.hpp.

◆ erase() [1/3]

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::erase ( const Const_iterator it)

Erases the element pointed to by the given valid iterator.

Behavior undefined if it is not valid. it becomes invalid.

Parameters
itIterator of element to erase.
Returns
Iterator one position past (i.e., "older") than it, before *it was removed.

Definition at line 653 of file linked_hash_set.hpp.

Referenced by flow::net_flow::Event_set::remove_wanted_socket().

Here is the caller graph for this function:

◆ erase() [2/3]

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::erase ( const Const_iterator it_newest,
const Const_iterator it_past_oldest 
)

Erases all elements in the range [it_newest, it_past_oldest).

Behavior undefined if a given iterator is invalid, or if the range is invalid. Corner case: an empty range is allowed; then this no-ops. Unless no-op, it_newest becomes invalid.

Parameters
it_newestIterator of first ("newest") element to erase.
it_past_oldestIterator of one past last ("oldest") element to erase.
Returns
it_past_oldest copy.

Definition at line 661 of file linked_hash_set.hpp.

◆ erase() [3/3]

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::size_type flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::erase ( const Key key)

Erases the element with the given key, if it exists.

find(key) equivalent is performed first. Return value indicates whether it existed.

Parameters
keyKey such that its equal's (if found) element will be erased.
Returns
Number of elements erased (0 or 1).

Definition at line 673 of file linked_hash_set.hpp.

◆ find()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Const_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::find ( const Key key) const

Attempts to find value at the given key in the map.

Key presence is determined identically to how it would be done in an unordered_set<Key_t, Hash_t, Pred_t>, with the particular Hash and Pred instances given to ctor (typically their default-cted instances, typically occupying no memory).

The returned iterator (if valid) cannot be used to mutate the key inside the map.

Parameters
keyKey whose equal to find.
Returns
If found, iterator to the key/mapped-value pair with the equivalent key; else this->end().

Definition at line 618 of file linked_hash_set.hpp.

◆ insert() [1/2]

template<typename Key_t , typename Hash_t , typename Pred_t >
std::pair< typename Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator, bool > flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::insert ( const Key key)

Attempts to insert (copying it) the given keyinto the map; if key already in *this makes no change.

See also the overload which can avoid a copy and destructively move the key instead.

Return value indicates various info of interest about what occurred or did not occur. If inserted, the new element is considered "newest," as if by touch(). If not inserted, the existing element location is not affected (use touch() upon consulting the return value, if this is desirable).

Parameters
keyThe key to attempt to insert. A copy of this value is placed in *this.
Returns
A pair whose second element is true if and only if the insertion occurred; and whose first element is an iterator pointing to either the newly inserted element or already present one with a key equal to key.

Definition at line 571 of file linked_hash_set.hpp.

Referenced by flow::net_flow::Node::event_set_all_check_delta(), and flow::net_flow::Node::event_set_check_baseline().

Here is the caller graph for this function:

◆ insert() [2/2]

template<typename Key_t , typename Hash_t , typename Pred_t >
std::pair< typename Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator, bool > flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::insert ( Key &&  key)

Identical to the other overload, except that (if key not already present in *this) the key is moved, not copied, into *this.

Parameters
keyThe key to attempt to insert (it is moved-from, if insertion occurs).
Returns
See other overload.

Definition at line 596 of file linked_hash_set.hpp.

◆ max_size()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::size_type flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::max_size

Returns max number of elements that can be stored.

Same performance as of unordered_set<> + list<>.

Returns
Ditto.

Definition at line 823 of file linked_hash_set.hpp.

◆ newest()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::newest

Returns first, a/k/a "newest," element's iterator (to immutable element, due to nature of this type).

Returns
Ditto.

Definition at line 698 of file linked_hash_set.hpp.

◆ oldest()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Reverse_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::oldest

Returns first, a/k/a "oldest," element's reverse iterator (to immutable element, due to nature of this type).

Returns
Ditto.

Definition at line 754 of file linked_hash_set.hpp.

◆ operator=() [1/2]

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t > & flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::operator= ( const Linked_hash_set< Key_t, Hash_t, Pred_t > &  src)

Overwrites this object with a copy of the given source.

We become equal to src but independent of it to a common-sense extent. In addition, the hasher instance and equality predicate are copied from src. Finally, a reasonable attempt is made to also make the internal structure of the hash map to be similar to that of `src.

Parameters
srcSource object. No-op if this == &src.
Returns
*this.

Definition at line 517 of file linked_hash_set.hpp.

References flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::m_value_iter_set, and flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::m_value_list.

◆ operator=() [2/2]

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t > & flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::operator= ( Linked_hash_set< Key_t, Hash_t, Pred_t > &&  src)

Overwrites this object making it identical to the given source, while the given source becomes as-if default-cted.

This is a constant-time operation, plus whatever is the cost of this->clear() (linear in pre-op .size()).

Parameters
srcSource object which is emptied; except no-op if this == &src.
Returns
*this.

Definition at line 549 of file linked_hash_set.hpp.

References flow::util::swap().

Here is the call graph for this function:

◆ past_newest()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Reverse_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::past_newest

Returns one past last, a/k/a "newest," element's reverse iterator (to immutable element, due to nature of this type).

Returns
Ditto.

Definition at line 782 of file linked_hash_set.hpp.

◆ past_oldest()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::past_oldest

Returns one past last, a/k/a "oldest," element's iterator (to immutable element, due to nature of this type).

Returns
Ditto.

Definition at line 726 of file linked_hash_set.hpp.

◆ rbegin()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Reverse_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::rbegin

Synonym of oldest().

Returns
See oldest().

Definition at line 768 of file linked_hash_set.hpp.

◆ rend()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::Reverse_iterator flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::rend

Synonym of past_newest().

Exists as standard container method.

Returns
See past_newest().

Definition at line 796 of file linked_hash_set.hpp.

◆ size()

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_set< Key_t, Hash_t, Pred_t >::size_type flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::size

Returns number of elements stored.

Same performance as of unordered_set<>.

Returns
Ditto.

Definition at line 810 of file linked_hash_set.hpp.

Referenced by flow::net_flow::Event_set::clear_result_sockets(), flow::net_flow::Event_set::clear_wanted_sockets(), flow::net_flow::Event_set::emit_result_sockets(), flow::net_flow::Node::event_set_all_check_delta(), and flow::net_flow::Event_set::swap_wanted_sockets().

Here is the caller graph for this function:

◆ swap()

template<typename Key_t , typename Hash_t , typename Pred_t >
void flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::swap ( Linked_hash_set< Key_t, Hash_t, Pred_t > &  other)

Swaps the contents of this structure and other.

This is a constant-time operation, as internal representations are swapped instead of any copy-assignment.

See also
The swap() free function. It is generally best (equivalent but covers more generic cases) to use the ADL-enabled swap(a, b) pattern instead of this member function. That is: using std::swap; ...; swap(a, b);. (Details are outside our scope here; but in short ADL will cause the right thing to happen.)
Parameters
otherThe other structure.

Definition at line 560 of file linked_hash_set.hpp.

References flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::m_value_iter_set, flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::m_value_list, and flow::util::swap().

Referenced by flow::net_flow::Event_set::emit_result_sockets(), flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::swap(), and flow::net_flow::Event_set::swap_wanted_sockets().

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

◆ touch() [1/2]

template<typename Key_t , typename Hash_t , typename Pred_t >
void flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::touch ( const Const_iterator it)

Given a valid iterator into the structure, makes the pointed-to element "newest" by moving it from wherever it is to be first in the iteration order.

Behavior undefined if iterator invalid.

The iterator continues to be valid.

Parameters
itIterator to an element of the structure.

Definition at line 632 of file linked_hash_set.hpp.

◆ touch() [2/2]

template<typename Key_t , typename Hash_t , typename Pred_t >
bool flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::touch ( const Key key)

Given a key into the structure, makes the corresponding element "newest" by moving it from wherever it is to be first in the iteration order; or does nothing if no such key.

find(key) equivalent is performed first. Return value indicates whether it was found.

Parameters
keyKey whose equal to find.
Returns
true if the key was found (even if it was already "newest"); false if not found.

Definition at line 638 of file linked_hash_set.hpp.

Friends And Related Function Documentation

◆ swap()

template<typename Key_t , typename Hash_t , typename Pred_t >
void swap ( Linked_hash_set< Key_t, Hash_t, Pred_t > &  val1,
Linked_hash_set< Key_t, Hash_t, Pred_t > &  val2 
)
related

Equivalent to val1.swap(val2).

Parameters
val1Object.
val2Object.

Definition at line 829 of file linked_hash_set.hpp.

References flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::swap().

Here is the call graph for this function:

Member Data Documentation

◆ m_value_iter_set

template<typename Key_t , typename Hash_t , typename Pred_t >
Linked_hash_key_set<Key, Iterator, Hash, Pred, false> flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::m_value_iter_set
private

Analogous to Linked_hash_map::m_value_iter_set; just configured to generate a simpler .iter() off each element by supplying false instead of true for the last template arg.

Definition at line 462 of file linked_hash_set.hpp.

Referenced by flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::Linked_hash_set(), flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::operator=(), and flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::swap().

◆ m_value_list

template<typename Key_t , typename Hash_t , typename Pred_t >
Value_list flow::util::Linked_hash_set< Key_t, Hash_t, Pred_t >::m_value_list
private

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