58template<
typename Key_t,
typename Hash_t,
typename Pred_t>
145 const Hash& hasher_obj = {},
146 const Pred& pred = {});
169 const Hash& hasher_obj = {},
170 const Pred& pred = {});
470template<
typename Key_t,
typename Hash_t,
typename Pred_t>
472 const Hash& hasher_obj,
481template<
typename Key_t,
typename Hash_t,
typename Pred_t>
484 const Hash& hasher_obj,
487 m_value_list(values),
493 for (
auto value_list_it =
m_value_list.cbegin(); value_list_it != value_list_end_it; ++value_list_it)
500template<
typename Key_t,
typename Hash_t,
typename Pred_t>
507template<
typename Key_t,
typename Hash_t,
typename Pred_t>
511 operator=(std::move(src));
514template<
typename Key_t,
typename Hash_t,
typename Pred_t>
522 using Value_iter_set =
decltype(m_value_iter_set);
533 m_value_iter_set = Value_iter_set{src_value_iter_set.bucket_count(),
534 src_value_iter_set.hash_function(),
535 src_value_iter_set.key_eq()};
537 const auto value_list_end_it = m_value_list.cend();
538 for (
auto value_list_it = m_value_list.cbegin(); value_list_it != value_list_end_it; ++value_list_it)
540 m_value_iter_set.insert(value_list_it);
546template<
typename Key_t,
typename Hash_t,
typename Pred_t>
558template<
typename Key_t,
typename Hash_t,
typename Pred_t>
568template<
typename Key_t,
typename Hash_t,
typename Pred_t>
569std::pair<typename Linked_hash_set<Key_t, Hash_t, Pred_t>::Iterator,
bool>
574 const auto set_it = m_value_iter_set.find(key);
575 if (set_it != m_value_iter_set.end())
577 return pair<Iterator, bool>{set_it->iter(),
false};
583 m_value_list.emplace_front(key);
588 const auto list_it = m_value_list.cbegin();
589 m_value_iter_set.insert(list_it);
590 return pair<Iterator, bool>{list_it,
true};
593template<
typename Key_t,
typename Hash_t,
typename Pred_t>
594std::pair<typename Linked_hash_set<Key_t, Hash_t, Pred_t>::Iterator,
bool>
601 const auto set_it = m_value_iter_set.find(key);
602 if (set_it != m_value_iter_set.end())
604 return pair<Iterator, bool>{set_it->iter(),
false};
608 m_value_list.emplace_front(std::move(key));
610 const auto list_it = m_value_list.cbegin();
611 m_value_iter_set.insert(list_it);
612 return pair<Iterator, bool>{list_it,
true};
615template<
typename Key_t,
typename Hash_t,
typename Pred_t>
619 const auto set_it = m_value_iter_set.find(key);
620 return (set_it == m_value_iter_set.cend()) ? m_value_list.cend() : set_it->iter();
623template<
typename Key_t,
typename Hash_t,
typename Pred_t>
627 return m_value_iter_set.count(key);
630template<
typename Key_t,
typename Hash_t,
typename Pred_t>
633 m_value_list.splice(m_value_list.begin(), m_value_list, it);
636template<
typename Key_t,
typename Hash_t,
typename Pred_t>
639 const auto it = find(key);
650template<
typename Key_t,
typename Hash_t,
typename Pred_t>
654 m_value_iter_set.erase(*it);
655 return m_value_list.erase(it);
658template<
typename Key_t,
typename Hash_t,
typename Pred_t>
662 for (
auto it = it_newest; it != it_past_oldest; ++it)
664 m_value_iter_set.erase(*it);
667 return m_value_list.erase(it_newest, it_past_oldest);
670template<
typename Key_t,
typename Hash_t,
typename Pred_t>
674 const auto set_it = m_value_iter_set.find(key);
675 if (set_it == m_value_iter_set.end())
681 const auto list_it = set_it->iter();
682 m_value_iter_set.erase(set_it);
683 m_value_list.erase(list_it);
688template<
typename Key_t,
typename Hash_t,
typename Pred_t>
691 m_value_iter_set.clear();
692 m_value_list.clear();
695template<
typename Key_t,
typename Hash_t,
typename Pred_t>
699 return m_value_list.cbegin();
702template<
typename Key_t,
typename Hash_t,
typename Pred_t>
709template<
typename Key_t,
typename Hash_t,
typename Pred_t>
716template<
typename Key_t,
typename Hash_t,
typename Pred_t>
723template<
typename Key_t,
typename Hash_t,
typename Pred_t>
727 return m_value_list.cend();
730template<
typename Key_t,
typename Hash_t,
typename Pred_t>
734 return past_oldest();
737template<
typename Key_t,
typename Hash_t,
typename Pred_t>
741 return past_oldest();
744template<
typename Key_t,
typename Hash_t,
typename Pred_t>
751template<
typename Key_t,
typename Hash_t,
typename Pred_t>
755 return m_value_list.crbegin();
758template<
typename Key_t,
typename Hash_t,
typename Pred_t>
765template<
typename Key_t,
typename Hash_t,
typename Pred_t>
772template<
typename Key_t,
typename Hash_t,
typename Pred_t>
779template<
typename Key_t,
typename Hash_t,
typename Pred_t>
783 return m_value_list.crend();
786template<
typename Key_t,
typename Hash_t,
typename Pred_t>
790 return past_newest();
793template<
typename Key_t,
typename Hash_t,
typename Pred_t>
797 return past_newest();
800template<
typename Key_t,
typename Hash_t,
typename Pred_t>
804 return m_value_list.rend();
807template<
typename Key_t,
typename Hash_t,
typename Pred_t>
811 return m_value_iter_set.size();
814template<
typename Key_t,
typename Hash_t,
typename Pred_t>
817 return m_value_list.empty();
820template<
typename Key_t,
typename Hash_t,
typename Pred_t>
824 return std::min(m_value_iter_set.max_size(), m_value_list.max_size());
827template<
typename Key_t,
typename Hash_t,
typename Pred_t>
An object of this class is a set that combines the lookup speed of an unordered_flat_set<> and orderi...
Hash hasher
For container compliance (hence the irregular capitalization): Hash type.
Value * pointer
For container compliance (hence the irregular capitalization): pointer to Key type.
Linked_hash_set(const Linked_hash_set &src)
Constructs object that is a copy of the given source.
Const_iterator cbegin() const
Synonym of const_newest().
Const_reverse_iterator const_oldest() const
Returns first, a/k/a "oldest," element's reverse iterator (to immutable element).
Pred_t Pred
Convenience alias for template arg.
void swap(Linked_hash_set &other)
Swaps the contents of this structure and other.
Linked_hash_set & operator=(Linked_hash_set &&src)
Overwrites this object making it identical to the given source, while the given source becomes as-if ...
Const_reverse_iterator Reverse_iterator
Type for reverse iterator pointing into a mutable structure of this type but actually that is not pos...
void clear()
Makes it so that size() == 0.
bool empty() const
Returns true if and only if container is empty.
Value value_type
For container compliance (hence the irregular capitalization): Value type.
Reverse_iterator rend() const
Synonym of past_newest().
std::pair< Iterator, bool > insert(const Key &key)
Attempts to insert (copying it) the given keyinto the map; if key already in *this makes no change.
std::size_t size_type
Expresses sizes/lengths of relevant things.
Const_iterator erase(const Const_iterator &it)
Erases the element pointed to by the given valid iterator.
Linked_hash_set & operator=(const Linked_hash_set &src)
Overwrites this object with a copy of the given source.
Linked_hash_set(Linked_hash_set &&src)
Constructs object by making it equal to the given source, while the given source becomes as-if defaul...
Const_reverse_iterator const_past_newest() const
Returns one past last, a/k/a "newest," element's reverse iterator (to immutable element).
size_type size() const
Returns number of elements stored.
Linked_hash_set(size_type n_buckets=size_type(-1), const Hash &hasher_obj={}, const Pred &pred={})
Constructs empty structure with some basic parameters.
std::pair< Iterator, bool > insert(Key &&key)
Identical to the other overload, except that (if key not already present in *this) the key is moved,...
Reverse_iterator rbegin() const
Synonym of oldest().
Const_iterator const_past_oldest() const
Returns one past last, a/k/a "oldest," element's iterator (to immutable element).
Const_iterator cend() const
Synonym of const_past_oldest().
Pred key_equal
For container compliance (hence the irregular capitalization): Pred type.
Key Value
Short-hand for values, which in this case are simply the keys.
const Value * const_pointer
For container compliance (hence the irregular capitalization): pointer to const Key type.
void touch(const Const_iterator &it)
Given a valid iterator into the structure, makes the pointed-to element "newest" by moving it from wh...
typename Value_list::const_reverse_iterator Const_reverse_iterator
Type for reverse iterator pointing into an immutable structure of this type.
Const_iterator const_newest() const
Returns first, a/k/a "newest," element's iterator (to immutable element).
Const_iterator const_iterator
For container compliance (hence the irregular capitalization): Const_iterator type.
Iterator begin() const
Synonym of newest().
Reverse_iterator oldest() const
Returns first, a/k/a "oldest," element's reverse iterator (to immutable element, due to nature of thi...
size_type erase(const Key &key)
Erases the element with the given key, if it exists.
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).
Key key_type
For container compliance (hence the irregular capitalization): Key type.
Iterator past_oldest() const
Returns one past last, a/k/a "oldest," element's iterator (to immutable element, due to nature of thi...
Const_iterator Iterator
Type for iterator pointing into a mutable structure of this type but actually that is not possible; s...
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: ei...
Key_t Key
Convenience alias for template arg.
size_type max_size() const
Returns max number of elements that can be stored.
const Value & const_reference
For container compliance (hence the irregular capitalization): reference to const Key type.
typename Value_list::const_iterator Const_iterator
Type for iterator pointing into an immutable structure of this type.
Hash_t Hash
Convenience alias for template arg.
Linked_hash_set(std::initializer_list< Value > values, size_type n_buckets=size_type(-1), const Hash &hasher_obj={}, const Pred &pred={})
Constructs structure with some basic parameters, and values initialized from initializer list.
Iterator iterator
For container compliance (hence the irregular capitalization): Iterator type.
Const_iterator find(const Key &key) const
Attempts to find value at the given key in the map.
Iterator newest() const
Returns first, a/k/a "newest," element's iterator (to immutable element, due to nature of this type).
std::list< Value > Value_list
Short-hand for doubly linked list of Keys.
Value_list m_value_list
Analogous to Linked_hash_map::m_value_list; but simpler in that it just stores Keys,...
std::ptrdiff_t difference_type
Type for difference of size_types.
Const_reverse_iterator crend() const
Synonym of const_past_newest().
Iterator end() const
Synonym of past_oldest().
bool touch(const Key &key)
Given a key into the structure, makes the corresponding element "newest" by moving it from wherever i...
Reverse_iterator past_newest() const
Returns one past last, a/k/a "newest," element's reverse iterator (to immutable element,...
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 ....
Value & reference
For container compliance (hence the irregular capitalization): reference to Key type.
Const_reverse_iterator crbegin() const
Synonym of const_oldest().
Flow module containing miscellaneous general-use facilities that don't fit into any other Flow module...
constexpr size_t LINKED_HASH_KEY_SET_DEFAULT_N_BUCKETS
Value used by alias-target type of Linked_hash_key_set as the default hash bucket count,...
void swap(Basic_blob< Allocator_t, SHARING > &blob1, Basic_blob< Allocator_t, SHARING > &blob2, log::Logger *logger_ptr) noexcept
Equivalent to blob1.swap(blob2).
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).