13#if HX_USE_MACROS_WITH_MODULE
14#error Header does not provide macros alone.
50template<
typename key_t_,
131#if HX_CPLUSPLUS < 202002L
139 const key_t_&
key(
void)
const;
149 : m_map_(map_), m_index_(index_) { }
239 template<hx
size_t capacity_x_>
241 capacity_x_>& x_)
noexcept;
293 template<hx
size_t capacity_x_>
295 multi_t_, capacity_x_>& x_)
const;
345 template<hx
size_t capacity_x_>
347 multi_t_, capacity_x_>& x_)
const;
388 template<
typename,
typename,
typename,
bool, hx
size_t>
friend class hxflat_map;
390 template<
typename mapped_u_>
391 iterator insert_at_(
hxsize_t index_,
const key_t_& key_, mapped_u_&& mapped_)
noexcept;
400#if HX_CPLUSPLUS >= 202002L
403template<
typename key_t_,
typename mapped_t_,
typename compare_t_,
bool multi_t_,
414template<
typename key_t_,
typename mapped_t_,
typename compare_t_,
bool multi_t_,
425template<
typename key_t_,
typename mapped_t_,
typename compare_t_,
bool multi_t_>
433#include "detail/hxflat_map.inl"
hxallocator<1+> - Provides static allocation when capacity is greater than zero.
Definition hxallocator.hpp:25
const_iterator - A random-access iterator over key-value pairs.
Definition hxflat_map.hpp:65
const_iterator operator+(hxsize_t n_) const
Returns an iterator advanced by n positions.
Definition hxflat_map.hpp:85
const_iterator & operator--(void)
Retreats the iterator to the previous element.
Definition hxflat_map.hpp:106
bool operator==(const const_iterator &x_) const
Compares two iterators for equality.
const_iterator operator[](hxsize_t n_) const
Returns a copy of the iterator offset by n positions.
Definition hxflat_map.hpp:97
const_iterator & operator++(void)
Advances the iterator to the next element.
Definition hxflat_map.hpp:100
bool operator>=(const const_iterator &x_) const
Returns true when this iterator is not ordered before x.
Definition hxflat_map.hpp:129
const const_iterator & operator*(void) const
Returns a const reference to this iterator, allowing use as a proxy element.
Definition hxflat_map.hpp:73
bool operator>(const const_iterator &x_) const
Returns true when this iterator is ordered after x.
Definition hxflat_map.hpp:121
const_iterator & operator-=(hxsize_t n_)
Moves the iterator back by n positions.
Definition hxflat_map.hpp:81
bool operator<(const const_iterator &x_) const
Returns true when this iterator is ordered before x.
const_iterator operator--(int)
Retreats the iterator to the previous element (post-decrement).
Definition hxflat_map.hpp:109
const mapped_t_ & value(void) const
Returns the mapped value at the current position.
const_iterator operator-(hxsize_t n_) const
Returns an iterator retreated by n positions.
Definition hxflat_map.hpp:89
const_iterator operator++(int)
Advances the iterator to the next element (post-increment).
Definition hxflat_map.hpp:103
const key_t_ & key(void) const
Returns the key at the current position.
bool operator<=(const const_iterator &x_) const
Returns true when this iterator is not ordered after x.
Definition hxflat_map.hpp:125
hxsize_t operator-(const const_iterator &x_) const
Returns the signed distance between two iterators.
const_iterator & operator+=(hxsize_t n_)
Advances the iterator by n positions.
const_iterator(void)
Constructs an end iterator.
Definition hxflat_map.hpp:68
iterator - A mutable random-access iterator that allows modifying the mapped value.
Definition hxflat_map.hpp:157
iterator & operator+=(hxsize_t n_)
Advances the iterator by n positions.
Definition hxflat_map.hpp:169
iterator operator++(int)
Advances the iterator to the next element (post-increment).
Definition hxflat_map.hpp:195
mapped_t_ & value(void) const
Returns the mapped value at the current position, allowing mutation.
iterator operator+(hxsize_t n_) const
Returns an iterator advanced by n positions.
Definition hxflat_map.hpp:177
iterator(void)
Constructs an end iterator.
Definition hxflat_map.hpp:160
iterator & operator-=(hxsize_t n_)
Moves the iterator back by n positions.
Definition hxflat_map.hpp:173
iterator operator[](hxsize_t n_) const
Returns a copy of the iterator offset by n positions.
Definition hxflat_map.hpp:189
iterator & operator++(void)
Advances the iterator to the next element.
Definition hxflat_map.hpp:192
iterator & operator--(void)
Retreats the iterator to the previous element.
Definition hxflat_map.hpp:198
iterator operator--(int)
Retreats the iterator to the previous element (post-decrement).
Definition hxflat_map.hpp:201
hxsize_t operator-(const const_iterator &x_) const
Returns the signed distance from x to this position.
Definition hxflat_map.hpp:185
iterator operator-(hxsize_t n_) const
Returns an iterator retreated by n positions.
Definition hxflat_map.hpp:181
const iterator & operator*(void) const
Returns a const reference to this iterator as a proxy element.
Definition hxflat_map.hpp:165
hxflat_map - A sorted associative container that stores keys and mapped values in two parallel arrays...
Definition hxflat_map.hpp:55
iterator upper_bound(const key_t_ &key_)
Non-const version of upper_bound.
const_iterator end(void) const
Returns a const iterator pointing past the last element.
Definition hxflat_map.hpp:285
iterator begin(void)
Returns an iterator pointing to the first element.
Definition hxflat_map.hpp:262
bool full(void) const
Returns true if the map has reached its capacity.
Definition hxflat_map.hpp:318
hxflat_map(hxflat_map &&x_) noexcept
Move constructs from a temporary hxflat_map.
hxsize_t capacity(void) const
Returns the number of elements the map can hold.
Definition hxflat_map.hpp:265
const_iterator begin(void) const
Returns a const iterator pointing to the first element.
Definition hxflat_map.hpp:259
iterator insert(const key_t_ &key_, const mapped_t_ &mapped_) noexcept
Inserts a key-value pair.
void reserve(hxsize_t cap_, hxsystem_allocator_t allocator_=hxsystem_allocator_current, hxalignment_t alignment_=hxalignment) noexcept
Allocates storage for cap keys and values.
key_t_ key_t
Definition hxflat_map.hpp:57
const mapped_t_ * find(const key_t_ &key_) const
Returns a const pointer to the mapped value for key, or hxnull if the key is not found.
iterator end(void)
Returns an iterator pointing past the last element.
Definition hxflat_map.hpp:288
compare_t_ compare_t
Definition hxflat_map.hpp:59
iterator erase(iterator pos_) noexcept
Removes the element at the iterator position and destroys the key-value pair.
mapped_t_ mapped_t
Definition hxflat_map.hpp:58
hxflat_map(void)
Constructs an empty map.
void swap(hxflat_map &x_) noexcept
Swaps the contents with x.
mapped_t_ * find(const key_t_ &key_)
Non-const version of find.
iterator lower_bound(const key_t_ &key_)
Non-const version of lower_bound.
hxsize_t max_size(void) const
Returns the capacity of the map.
Definition hxflat_map.hpp:359
bool equal(const hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, capacity_x_ > &x_) const
Returns true if this map and x contain the same key-value pairs in the same order using hxkey_equal o...
hxsize_t count(const key_t_ &key_) const
Returns the number of elements with the given key.
bool empty(void) const
Checks if the map contains no elements.
Definition hxflat_map.hpp:282
void operator=(const hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, capacity_x_ > &x_) noexcept
Cross-capacity copy assignment.
const_iterator lower_bound(const key_t_ &key_) const
Returns an iterator to the first element whose key is not ordered before key.
iterator insert(const key_t_ &key_, mapped_t_ &&mapped_) noexcept
Move-value overload of insert.
const_iterator cbegin(void) const
Returns a const iterator pointing to the first element (alias for begin).
Definition hxflat_map.hpp:269
void operator=(hxflat_map &&x_) noexcept
Move assigns from a temporary map using swap.
hxsize_t erase(const key_t_ &key_) noexcept
Removes all elements with the given key and destroys their key-value pairs.
hxsize_t size(void) const
Returns the number of elements in the map.
Definition hxflat_map.hpp:371
hxflat_map(const hxflat_map &x_) noexcept
Copy constructs from another hxflat_map.
iterator get(hxsize_t index_)
Non-const version of get.
const_iterator operator[](hxsize_t index_) const
Returns a const iterator to the element at index.
~hxflat_map(void) noexcept
Destructs the map and destroys all key-value pairs.
bool less(const hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, capacity_x_ > &x_) const
Returns true if this map compares less than x lexicographically, using hxkey_equal and hxkey_less on ...
const_iterator get(hxsize_t index_) const
Returns a const iterator to the element at index, or an end iterator if index is out of range.
iterator operator[](hxsize_t index_)
Returns an iterator to the element at index.
void operator=(const hxflat_map &x_) noexcept
Assigns the contents of x to this map.
const_iterator cend(void) const
Returns a const iterator pointing past the last element.
Definition hxflat_map.hpp:272
void clear(void) noexcept
Removes all elements and destroys their key-value pairs.
const_iterator upper_bound(const key_t_ &key_) const
Returns an iterator to the first element whose key is ordered after key.
hxkey_less_t<T> - A constexpr callable that invokes hxkey_less.
Definition hxkey.hpp:131
Similar to std::allocator.
HX_NS_BEGIN_ constexpr hxsize_t hxallocator_dynamic_capacity
hxallocator_dynamic_capacity - A capacity value that allows for dynamic allocation.
Definition hxallocator.hpp:20
void hxswap(hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, hxallocator_dynamic_capacity > &x_, hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, hxallocator_dynamic_capacity > &y_) noexcept
void hxswap(hxflat_map<K,V>& x, hxflat_map<K,V>& y) - Exchanges the contents of x and y.
Definition hxflat_map.hpp:426
bool hxkey_equal(const hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, capacity_x_ > &x_, const hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, capacity_y_ > &y_)
bool hxkey_equal(hxflat_map<K,V>& x, hxflat_map<K,V>& y) - Compares the contents of x and y for equiv...
Definition hxflat_map.hpp:405
bool hxkey_less(const hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, capacity_x_ > &x_, const hxflat_map< key_t_, mapped_t_, compare_t_, multi_t_, capacity_y_ > &y_)
bool hxkey_less(hxflat_map<K,V>& x, hxflat_map<K,V>& y) - Compares the contents of x and y lexicograp...
Definition hxflat_map.hpp:416
User-overloadable key-equal, key-less, and key-hash functions.
@ hxsystem_allocator_current
hxsystem_allocator_current - Use current allocation scope.
Definition hxmemory_manager.h:82
int hxsystem_allocator_t
hxsystem_allocator_t - This is extendable by the application.
Definition hxmemory_manager.h:77
unsigned int hxalignment_t
hxalignment_t - A positive integer power of 2 for aligning allocations.
Definition hxmemory_manager.h:64
constexpr hxalignment_t hxalignment
hxalignment - The default alignment.
Definition hxmemory_manager.h:69
#define hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:120
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:89
#define hxattr_flatten
hxattr_flatten - Inline every call inside a function's body into it, recursively, regardless of the c...
Definition hxsettings.h:82
Standard sorting utilities.
void hxswap_memcpy(T &x_, T &y_)
hxswap_memcpy - Exchanges the contents of x and y using memcpy and a stack temporary.
Definition hxutility.h:354
Provides core macros, memory management and feature detection.
#define hxnull
hxnull - The null pointer value for a given pointer type represented by the numeric constant 0.
Definition libhatchet.h:277
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:209