|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Generic domain class based on hash set. More...
#include <al-domain.H>
Public Types | |
| using | Base = Aleph::HashSet< T, SetODhash > |
| typedef HashSetTable< Key, Cmp > | Base |
Public Types inherited from Aleph::HashSet< Key, HashSetTable, Cmp > | |
| typedef HashSetTable< Key, Cmp > | Base |
Public Member Functions | |
| const DynList< T > & | keys () const |
| Get sorted list of all elements in the domain. | |
| T * | insert (const T &key) |
Insert key, as HashSet::insert(), and forget the sorted keys. | |
| T * | insert (T &&key) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| T * | search_or_insert (const T &key) |
Search or insert key, as HashSet::search_or_insert(), and forget the sorted keys. | |
| T * | search_or_insert (T &&key) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::pair< T *, bool > | contains_or_insert (const T &key) |
Search or insert key, as HashSet::contains_or_insert(), and forget the sorted keys. | |
| std::pair< T *, bool > | contains_or_insert (T &&key) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| T * | append (const T &key) |
Insert key, as HashSet::append(), and forget the sorted keys. | |
| T * | append (T &&key) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | add (const DynList< T > &l) |
Insert the keys of l, as HashSet::add(), and forget the sorted keys. | |
| void | remove (const T &key) |
Remove key, as HashSet::remove(), and forget the sorted keys. | |
| void | remove_ptr (T *key) |
Remove the key that key points to, as HashSet::remove_ptr(), and forget the sorted keys. | |
| void | empty () |
| Remove every key, as HashSet::empty(), and forget the sorted keys. | |
| void | clear () |
| Remove every key, as HashSet::clear(), and forget the sorted keys. | |
| void | swap (AlDomain &other) noexcept |
Swap the keys, and the sorted keys, with other. | |
| DynList< T > | to_list () const |
| Convert domain to sorted list. | |
| std::string | to_str () const and AlStreamable< T > |
| Convert domain to string representation. | |
Public Member Functions inherited from Aleph::HashSet< Key, HashSetTable, Cmp > | |
| void | add (const DynList< Key > &l) |
| template<template< typename > class List> | |
| HashSet (const List< Key > &l) | |
| template<class It > requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; }) | |
| HashSet (It b, It e) | |
| HashSet (std::initializer_list< Key > l) | |
| HashSet () | |
| const Key & | get_first () const |
| const Key & | get_last () const |
| void | clear () |
| Empties the container. | |
| bool | is_empty () const noexcept |
| Checks if the container is empty. | |
Static Public Member Functions | |
| template<typename... Items> requires requires (Items &&... items) { AlDomain ::template build_as< AlDomain >(std::forward<Items>(items)...); } | |
| static AlDomain | build (Items &&... items) |
Static Public Member Functions inherited from Aleph::HashSet< Key, HashSetTable, Cmp > | |
| template<typename... Items> requires requires (Items &&... items) { HashSet ::template build_as< HashSet >(std::forward<Items>(items)...); } | |
| static HashSet | build (Items &&... items) |
Private Attributes | |
| bool | keys_build = false |
| Lazy cache flag. | |
| DynList< T > | domain |
| Cached sorted keys. | |
Generic domain class based on hash set.
Stores a set of unique elements with O(1) lookup. Provides sorted iteration via the keys() method.
keys() keeps the sorted elements until the domain changes: the members of AlDomain that insert or remove forget them, and keys() sorts them again also when the number of elements changed by other means, as the removal through an iterator.
| T | Element type (default: int) |
Definition at line 131 of file al-domain.H.
| using Aleph::AlDomain< T >::Base = Aleph::HashSet<T, SetODhash> |
Definition at line 138 of file al-domain.H.
| typedef HashSetTable<Key, Cmp> Aleph::HashSet< Key, HashSetTable, Cmp >::Base |
Definition at line 64 of file tpl_hash.H.
|
inline |
Insert the keys of l, as HashSet::add(), and forget the sorted keys.
Definition at line 220 of file al-domain.H.
References Aleph::HashSet< Key, HashSetTable, Cmp >::add(), Aleph::AlDomain< T >::keys_build, and l.
Referenced by TEST().
|
inline |
Insert key, as HashSet::append(), and forget the sorted keys.
Definition at line 206 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
Referenced by TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 213 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
|
inlinestatic |
Definition at line 140 of file al-domain.H.
Referenced by TEST().
|
inline |
Remove every key, as HashSet::clear(), and forget the sorted keys.
Definition at line 249 of file al-domain.H.
References Aleph::AlDomain< T >::empty().
Referenced by TEST().
|
inline |
Search or insert key, as HashSet::contains_or_insert(), and forget the sorted keys.
Definition at line 192 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
Referenced by TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 199 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
|
inline |
Remove every key, as HashSet::empty(), and forget the sorted keys.
Definition at line 242 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
Referenced by Aleph::AlDomain< T >::clear(), and TEST().
|
inline |
Insert key, as HashSet::insert(), and forget the sorted keys.
Definition at line 162 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
Referenced by VectorTest::SetUp(), TEST(), TEST(), TEST(), and TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 169 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
|
inline |
Get sorted list of all elements in the domain.
Lazily builds and caches the sorted key list, which a later change of the domain rebuilds.
Definition at line 151 of file al-domain.H.
References Aleph::AlDomain< T >::domain, Aleph::AlDomain< T >::keys_build, Aleph::DynList< T >::size(), and Aleph::sort().
Referenced by TEST_F(), and Aleph::AlDomain< T >::to_list().
|
inline |
Remove key, as HashSet::remove(), and forget the sorted keys.
Definition at line 227 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
Referenced by TEST().
|
inline |
Remove the key that key points to, as HashSet::remove_ptr(), and forget the sorted keys.
Definition at line 235 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
Referenced by TEST().
|
inline |
Search or insert key, as HashSet::search_or_insert(), and forget the sorted keys.
Definition at line 177 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
Referenced by TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 184 of file al-domain.H.
References Aleph::AlDomain< T >::keys_build.
|
inlinenoexcept |
Swap the keys, and the sorted keys, with other.
Definition at line 252 of file al-domain.H.
References Aleph::AlDomain< T >::domain, Aleph::AlDomain< T >::keys_build, and Aleph::DynList< T >::swap().
Referenced by TEST().
|
inline |
Convert domain to sorted list.
Definition at line 263 of file al-domain.H.
References Aleph::AlDomain< T >::keys().
Referenced by TEST_F(), and Aleph::AlDomain< T >::to_str().
|
inline |
Convert domain to string representation.
Definition at line 269 of file al-domain.H.
References Aleph::sort(), Aleph::AlDomain< T >::to_list(), and Aleph::to_str().
Referenced by Aleph::operator<<().
|
mutableprivate |
Cached sorted keys.
Definition at line 134 of file al-domain.H.
Referenced by Aleph::AlDomain< T >::keys(), and Aleph::AlDomain< T >::swap().
|
mutableprivate |
Lazy cache flag.
Definition at line 133 of file al-domain.H.
Referenced by Aleph::AlDomain< T >::add(), Aleph::AlDomain< T >::append(), Aleph::AlDomain< T >::append(), Aleph::AlDomain< T >::contains_or_insert(), Aleph::AlDomain< T >::contains_or_insert(), Aleph::AlDomain< T >::empty(), Aleph::AlDomain< T >::insert(), Aleph::AlDomain< T >::insert(), Aleph::AlDomain< T >::keys(), Aleph::AlDomain< T >::remove(), Aleph::AlDomain< T >::remove_ptr(), Aleph::AlDomain< T >::search_or_insert(), Aleph::AlDomain< T >::search_or_insert(), and Aleph::AlDomain< T >::swap().