68 template <
typename Key,
typename ValueType>
110 template <
typename... Pairs>
174 for (
auto it =
tbl.
get_it(); it.has_curr(); it.next())
176 auto curr = it.get_curr();
177 ret.
insert(curr.second, curr.first);
226 for (
auto it =
tbl.
get_it(); it.has_curr(); it.next())
227 result.
append(it.get_curr().second);
264 for (
auto it =
tbl.
get_it(); it.has_curr(); it.next())
265 if (it.get_curr().second ==
value)
275 template <
typename F>
278 static_assert(std::is_invocable_v<F, const Key &, const ValueType &>,
279 "Function must take (const Key&, const ValueType&) parameters");
281 for (
auto it =
tbl.
get_it(); it.has_curr(); it.next())
283 const auto &
pair = it.get_curr();
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
size_t size_t int32_t value
A generic key-value mapping container with inverse operation support.
bool remove(const Key &key) noexcept
Removes the key-value pair with the given key.
DynList< ValueType > values() const
Gets all values in the mapping.
size_t size_type
Type for size-related operations.
AHMapping(const Key &key, const ValueType &value, Pairs... pairs)
Constructs a mapping from a list of key-value pairs.
AHMapping()=default
Default constructor.
AHMapping(AHMapping &&other)=default
Move constructor.
size_t size() const noexcept
Gets the number of key-value pairs in the mapping.
AHMapping(const AHMapping &other)=default
Copy constructor.
bool valid_key(const Key &key) const noexcept
Checks if a key exists in the mapping.
Key key_type
Type of the keys.
AHMapping< ValueType, Key > inverse() const
Creates a new mapping with keys and values swapped.
AHMapping & operator=(AHMapping &&other) noexcept=default
Move assignment operator.
DynMapTree< Key, ValueType > tbl
const ValueType & operator[](const Key &key) const
Accesses the value associated with the given key.
ValueType mapped_type
Type of the mapped values.
bool contains_value(const ValueType &value) const
Checks if the mapping contains a specific value.
ValueType & operator[](const Key &key)
Accesses the value associated with the given key.
std::pair< const Key, ValueType > value_type
Type of the key-value pairs.
void insert(const Key &key, const ValueType &value)
Inserts or updates a key-value pair in the mapping.
void for_each(F f) const
Applies a function to each key-value pair.
void clear() noexcept
Removes all key-value pairs from the mapping.
AHMapping & operator=(const AHMapping &other)=default
Copy assignment operator.
bool empty() const noexcept
Checks if the mapping is empty.
DynList< Key > keys() const
Gets all keys in the mapping.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
Generic key-value map implemented on top of a binary search tree.
Data remove(const Key &key)
Deletes the pair key,data
Pair * search(const Key &key) noexcept(nothrow_search)
Collect all keys.
DynList< Key > keys() const
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
bool has(const Key &key) const noexcept(nothrow_search)
Return whether key is in the map.
const size_t & size() const
Returns the cardinality of the set.
void empty()
Remove all the elements of the set.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
Main namespace for Aleph-w library functions.
std::pair< First, Second > pair
Alias to std::pair kept for backwards compatibility.
Dynamic key-value map based on balanced binary search trees.