68 template <
typename Key,
typename ValueType>
105 template <
typename...
Pairs>
169 for (
auto it =
tbl.
get_it(); it.has_curr(); it.next())
171 auto curr = it.get_curr();
221 for (
auto it =
tbl.
get_it(); it.has_curr(); it.next())
222 result.
append(it.get_curr().second);
259 for (
auto it =
tbl.
get_it(); it.has_curr(); it.next())
260 if (it.get_curr().second == value)
270 template <
typename F>
273 static_assert(std::is_invocable_v<F, const Key &, const ValueType &>,
274 "Function must take (const Key&, const ValueType&) parameters");
276 for (
auto it =
tbl.
get_it(); it.has_curr(); it.next())
278 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.
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.
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.
AHMapping(AHMapping &&other) noexcept=default
Move constructor.
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.
Dynamic singly linked list with functional programming support.
T & insert(const T &item)
Insert a new item by copy.
T & append(const T &item)
Append a new item by copy.
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) const noexcept
Collect all keys.
bool has(const Key &key) const noexcept
DynList< Key > keys() const
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
const size_t & size() const
Returns the cardinality of the set.
void empty()
remove all elements from the set
auto get_it() const
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.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Dynamic key-value map based on balanced binary search trees.