12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
23#if HX_CPLUSPLUS >= 202002L
26concept hxflat_set_concept_ =
requires(T_& x_) {
32#define hxflat_set_concept_ typename
60template<hxflat_set_concept_ key_t_,
99#if HX_CPLUSPLUS >= 202302L
105 template<
typename self_t_,
typename callable_t_>
107 this self_t_&& self_,
const key_t_& key_, callable_t_&& callable_)
115 template<
typename self_t_,
typename callable_t_>
117 this self_t_&& self_,
const key_t_* it_, callable_t_&& callable_)
131 template<hx
size_t capacity_x_>
147 template<hx
size_t capacity_x_>
153 template<hx
size_t capacity_x_>
159 template<hxrange_concept_ range_t_>
166 template<hxrange_concept_ range_t_,
167 hxenable_if_t<!hxis_lvalue_reference<range_t_>(),
int> = 0>
171 const key_t_*
begin(
void)
const {
return this->
data(); }
180 const key_t_*
cend(
void)
const {
return m_end_; }
195 template<
typename... args_t_>
196 const key_t_*
emplace(args_t_&&... args_)
noexcept;
202 const key_t_*
end(
void)
const {
return m_end_; }
212 const key_t_*
erase(
const key_t_* it_)
noexcept;
231 const key_t_*
insert(
const key_t_& key_)
noexcept;
233 const key_t_*
insert(key_t_&& key_)
noexcept;
247#if HX_CPLUSPLUS >= 202302L
253 template<
typename self_t_,
typename callable_t_>
255 this self_t_&& self_,
const key_t_& key_, callable_t_&& callable_)
256 ->
decltype(self_.end());
262 template<
typename self_t_,
typename callable_t_>
264 this self_t_&& self_,
const key_t_* it_, callable_t_&& callable_)
265 ->
decltype(self_.end());
291#if HX_CPLUSPLUS >= 202302L
296 template<
typename self_t_,
typename... args_t_>
298 this self_t_&& self_,
const key_t_& key_, args_t_&&... args_);
303 template<
typename self_t_,
typename... args_t_>
305 this self_t_&& self_,
const key_t_* it_, args_t_&&... args_);
310 template<hxflat_set_concept_,
typename,
bool, hx
size_t>
friend class hxflat_set;
312 template<
typename key_u_>
313 const key_t_* insert_at_(key_t_* it_, key_u_&& key_)
noexcept;
319#include "detail/hxflat_set.inl"
hxallocator(void)
Definition hxallocator.hpp:35
const key_t_ * data(void) const
Definition hxallocator.hpp:45
bool operator==(const hxflat_set< key_t_, compare_t_, multi_t_, capacity_x_ > &x_) const
Returns true if this set and x contain the same keys in the same order using hxkey_equal.
~hxflat_set(void) noexcept
Destructs the set and destroys all keys.
hxflat_set(void)
Constructs an empty set.
const key_t_ * insert(key_t_ &&key_) noexcept
hxflat_set(std::initializer_list< key_t_ > x_) noexcept
Constructs a set by inserting every key from x in order using insert.
hxsize_t size(void) const
Returns the number of elements in the set.
Definition hxflat_set.hpp:280
hxsize_t capacity(void) const
Returns the capacity of the set or 0 if unallocated.
bool operator<(const hxflat_set< key_t_, compare_t_, multi_t_, capacity_x_ > &x_) const
Returns true if this set compares less than x lexicographically, using hxkey_equal and hxkey_less on ...
const key_t_ * keys(void) const noexcept
Returns a const pointer to the underlying key storage.
void swap(hxflat_set &x_) noexcept
Swaps the contents with x.
const key_t_ * upper_bound(const key_t_ &key_) const
Returns a const pointer to the first element whose key is ordered after key.
key_t_ value_or(this self_t_ &&self_, const key_t_ &key_, args_t_ &&... args_)
Returns a copy of the first key matching key, or a key constructed from args when lookup fails.
void operator=(hxflat_set &&x_) noexcept
Move assigns from a temporary set using swap.
bool has_value(const key_t_ &key_) const
Returns true if a key matching key exists.
const key_t_ * lower_bound(const key_t_ &key_) const
Returns a const pointer to the first element whose key is not ordered before key.
const key_t_ * const_iterator
const_iterator - Const random access iterator over keys.
Definition hxflat_set.hpp:73
hxflat_set(const hxflat_set &x_) noexcept
Copy constructs from another hxflat_set.
const key_t_ * erase(const key_t_ *it_) noexcept
Removes the element at the pointer position and destroys the key.
compare_t_ compare_t
Definition hxflat_set.hpp:67
void add_range(range_t_ &&range_) noexcept
Inserts every key from a temporary range by moving each key with insert.
const key_t_ * iterator
iterator - Const random access iterator over keys.
Definition hxflat_set.hpp:70
const key_t_ * insert(const key_t_ &key_) noexcept
Inserts a key.
bool full(void) const
Returns true if the set has reached its capacity.
Definition hxflat_set.hpp:220
const key_t_ * operator[](hxsize_t index_) const
Returns a const pointer to the element at index.
key_t_ value_or(this self_t_ &&self_, const key_t_ *it_, args_t_ &&... args_)
Iterator overload of value_or.
hxflat_set(hxflat_set &&x_) noexcept
Move constructs from a temporary hxflat_set.
hxsize_t max_size(void) const
Returns the capacity of the set.
Definition hxflat_set.hpp:245
bool empty(void) const
Checks if the set contains no elements.
Definition hxflat_set.hpp:199
const key_t_ * end(void) const
Returns a const pointer past the last element.
Definition hxflat_set.hpp:202
const key_t_ * find(const key_t_ &key_) const
Returns a const pointer to the key if found, or end() if not present.
const key_t_ * emplace(args_t_ &&... args_) noexcept
Constructs and inserts a key from args, returning a pointer to the new or existing key.
void clear(void) noexcept
Removes all elements and destroys their keys.
const key_t_ * begin(void) const
Returns a const pointer to the first element.
Definition hxflat_set.hpp:171
void add_range(range_t_ &range_) noexcept
Inserts every key from a range referenced by an lvalue by copying each key with insert.
void operator=(const hxflat_set< key_t_, compare_t_, multi_t_, capacity_x_ > &x_) noexcept
Cross-capacity copy assignment.
key_t_ key_t
Definition hxflat_set.hpp:66
void reserve(hxsize_t cap_, hxsystem_allocator_t allocator_=hxsystem_allocator_current, hxalignment_t alignment_=hxalignment)
Allocates storage for cap keys.
void operator=(const hxflat_set &x_) noexcept
Assigns the contents of x to this set.
auto or_else(this self_t_ &&self_, const key_t_ &key_, callable_t_ &&callable_) -> decltype(self_.end())
Returns a pointer to the first key matching key, or the result of calling callable when lookup fails.
hxsize_t count(const key_t_ &key_) const
Returns the number of elements with the given key.
auto and_then(this self_t_ &&self_, const key_t_ &key_, callable_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< const key_t_ & >())))>
Returns the result of calling callable with the first key matching key, otherwise returns hxnil.
auto or_else(this self_t_ &&self_, const key_t_ *it_, callable_t_ &&callable_) -> decltype(self_.end())
Iterator overload of or_else.
hxsize_t erase(const key_t_ &key_) noexcept
Removes all elements with the given key and destroys their keys.
auto and_then(this self_t_ &&self_, const key_t_ *it_, callable_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< const key_t_ & >())))>
Iterator overload of and_then.
const key_t_ * cend(void) const
Returns a const pointer past the last element.
Definition hxflat_set.hpp:180
const key_t_ * cbegin(void) const
Returns a const pointer to the first element (alias for begin).
Definition hxflat_set.hpp:177
hxkey_less_t<T> - A constexpr callable that returns true if the first object is less than the second.
Definition hxkey.hpp:91
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
Implements or includes std::initializer_list depending on HX_USE_LIBCXX.
User-specializable key-equal, key-less, and key-hash callables.
@ hxsystem_allocator_current
hxsystem_allocator_current - Use current allocation scope.
Definition hxmemory_manager.h:80
HX_C_BEGIN_ typedef unsigned int hxalignment_t
hxalignment_t - A positive integer power of 2 for aligning allocations.
Definition hxmemory_manager.h:62
int hxsystem_allocator_t
hxsystem_allocator_t - This is extendable by the application.
Definition hxmemory_manager.h:75
hxattr_noexcept hxsystem_allocator_t allocator_
Definition hxmemory_manager.h:120
hxattr_noexcept hxsystem_allocator_t hxalignment_t alignment_
Definition hxmemory_manager.h:121
constexpr hxalignment_t hxalignment
hxalignment - The default alignment.
Definition hxmemory_manager.h:67
Read-only range utilities for libhatchet.
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:98
constexpr T && hxforward(hxremove_reference_t< T > &&x_)
hxforward - Implements std::forward.
Definition hxutility.h:353
hxremove_cv_t< hxremove_reference_t< T > > hxremove_cvref_t
hxremove_cvref_t<T> - Returns T with const, volatile, and references removed.
Definition hxutility.h:103
T && hxdeclval(void) noexcept
hxdeclval - Implements std::declval.
constexpr hxforward_like_t_< like_t_, value_t_ > hxforward_like(value_t_ &value_)
hxforward_like<T> - Returns value with the constness and value category of T.
Definition hxutility.h:387
Provides core macros, memory management and feature detection.
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:207