58template<
typename Key_t,
typename Hash_t,
typename Pred_t>
469template<
typename Key_t,
typename Hash_t,
typename Pred_t>
471 const Hash& hasher_obj,
478template<
typename Key_t,
typename Hash_t,
typename Pred_t>
481 const Hash& hasher_obj,
484 m_value_list(values),
487 m_value_iter_set((n_buckets ==
size_type(-1))
488 ? boost::unordered::detail::default_bucket_count
494 for (
auto value_list_it =
m_value_list.cbegin(); value_list_it != value_list_end_it; ++value_list_it)
501template<
typename Key_t,
typename Hash_t,
typename Pred_t>
508template<
typename Key_t,
typename Hash_t,
typename Pred_t>
512 operator=(std::move(src));
515template<
typename Key_t,
typename Hash_t,
typename Pred_t>
523 using Value_iter_set =
decltype(m_value_iter_set);
534 m_value_iter_set = Value_iter_set{src_value_iter_set.bucket_count(),
535 src_value_iter_set.hash_function(),
536 src_value_iter_set.key_eq()};
538 const auto value_list_end_it = m_value_list.cend();
539 for (
auto value_list_it = m_value_list.cbegin(); value_list_it != value_list_end_it; ++value_list_it)
541 m_value_iter_set.insert(value_list_it);
547template<
typename Key_t,
typename Hash_t,
typename Pred_t>
559template<
typename Key_t,
typename Hash_t,
typename Pred_t>
569template<
typename Key_t,
typename Hash_t,
typename Pred_t>
570std::pair<typename Linked_hash_set<Key_t, Hash_t, Pred_t>::Iterator,
bool>
575 const auto set_it = m_value_iter_set.find(key);
576 if (set_it != m_value_iter_set.end())
578 return pair<Iterator, bool>{set_it->iter(),
false};
584 m_value_list.emplace_front(key);
589 const auto list_it = m_value_list.cbegin();
590 m_value_iter_set.insert(list_it);
591 return pair<Iterator, bool>{list_it,
true};
594template<
typename Key_t,
typename Hash_t,
typename Pred_t>
595std::pair<typename Linked_hash_set<Key_t, Hash_t, Pred_t>::Iterator,
bool>
602 const auto set_it = m_value_iter_set.find(key);
603 if (set_it != m_value_iter_set.end())
605 return pair<Iterator, bool>{set_it->iter(),
false};
609 m_value_list.emplace_front(std::move(key));
611 const auto list_it = m_value_list.cbegin();
612 m_value_iter_set.insert(list_it);
613 return pair<Iterator, bool>{list_it,
true};
616template<
typename Key_t,
typename Hash_t,
typename Pred_t>
620 const auto set_it = m_value_iter_set.find(key);
621 return (set_it == m_value_iter_set.cend()) ? m_value_list.cend() : set_it->iter();
624template<
typename Key_t,
typename Hash_t,
typename Pred_t>
628 return m_value_iter_set.count(key);
631template<
typename Key_t,
typename Hash_t,
typename Pred_t>
634 m_value_list.splice(m_value_list.begin(), m_value_list, it);
637template<
typename Key_t,
typename Hash_t,
typename Pred_t>
640 const auto it = find(key);
651template<
typename Key_t,
typename Hash_t,
typename Pred_t>
655 m_value_iter_set.erase(*it);
656 return m_value_list.erase(it);
659template<
typename Key_t,
typename Hash_t,
typename Pred_t>
663 for (
auto it = it_newest; it != it_past_oldest; ++it)
665 m_value_iter_set.erase(*it);
668 return m_value_list.erase(it_newest, it_past_oldest);
671template<
typename Key_t,
typename Hash_t,
typename Pred_t>
675 const auto set_it = m_value_iter_set.find(key);
676 if (set_it == m_value_iter_set.end())
682 const auto list_it = set_it->iter();
683 m_value_iter_set.erase(set_it);
684 m_value_list.erase(list_it);
689template<
typename Key_t,
typename Hash_t,
typename Pred_t>
692 m_value_iter_set.clear();
693 m_value_list.clear();
696template<
typename Key_t,
typename Hash_t,
typename Pred_t>
700 return m_value_list.cbegin();
703template<
typename Key_t,
typename Hash_t,
typename Pred_t>
710template<
typename Key_t,
typename Hash_t,
typename Pred_t>
717template<
typename Key_t,
typename Hash_t,
typename Pred_t>
724template<
typename Key_t,
typename Hash_t,
typename Pred_t>
728 return m_value_list.cend();
731template<
typename Key_t,
typename Hash_t,
typename Pred_t>
735 return past_oldest();
738template<
typename Key_t,
typename Hash_t,
typename Pred_t>
742 return past_oldest();
745template<
typename Key_t,
typename Hash_t,
typename Pred_t>
752template<
typename Key_t,
typename Hash_t,
typename Pred_t>
756 return m_value_list.crbegin();
759template<
typename Key_t,
typename Hash_t,
typename Pred_t>
766template<
typename Key_t,
typename Hash_t,
typename Pred_t>
773template<
typename Key_t,
typename Hash_t,
typename Pred_t>
780template<
typename Key_t,
typename Hash_t,
typename Pred_t>
784 return m_value_list.crend();
787template<
typename Key_t,
typename Hash_t,
typename Pred_t>
791 return past_newest();
794template<
typename Key_t,
typename Hash_t,
typename Pred_t>
798 return past_newest();
801template<
typename Key_t,
typename Hash_t,
typename Pred_t>
805 return m_value_list.rend();
808template<
typename Key_t,
typename Hash_t,
typename Pred_t>
812 return m_value_iter_set.size();
815template<
typename Key_t,
typename Hash_t,
typename Pred_t>
818 return m_value_list.empty();
821template<
typename Key_t,
typename Hash_t,
typename Pred_t>
825 return std::min(m_value_iter_set.max_size(), m_value_list.max_size());
828template<
typename Key_t,
typename Hash_t,
typename Pred_t>
An object of this class is a map that combines the lookup speed of an unordered_set<> and ordering an...
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.
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...
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.
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.
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.
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.
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...
void swap(Basic_blob< Allocator, SHARING > &blob1, Basic_blob< Allocator, 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).