12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
23#if HX_CPLUSPLUS >= 202002L
26concept hxarray_concept_ =
requires(T_& x_) {
32#define hxarray_concept_ typename
51template<hxarray_concept_ T_, hx
size_t capacity_=hxallocator_dynamic_capacity>
86 template<
typename other_value_t_, hx
size_t array_length_>
87 hxarray(
const other_value_t_(&array_)[array_length_])
noexcept;
92 template<
typename other_value_t_>
93 hxarray(std::initializer_list<other_value_t_> x_)
noexcept;
95#if HX_CPLUSPLUS >= 202002L
98 template<hxrange_concept_ range_t_>
106 template<hxrange_concept_ range_t_>
115#if HX_CPLUSPLUS >= 202302L
121 template<
typename self_t_,
typename callable_t_>
123 this self_t_&& self_,
hxsize_t index_, callable_t_&& callable_)
131 template<
typename self_t_,
typename callable_t_>
133 this self_t_&& self_,
const T_* it_, callable_t_&& callable_)
155 template<
typename other_value_t_, hx
size_t array_length_>
156 void operator=(
const other_value_t_(&array_)[array_length_])
noexcept;
173 template<
typename callable_t_>
176 template<
typename callable_t_>
188 template<
typename callable_t_>
191 template<
typename callable_t_>
241 template<
typename callable_t_>
244 template<
typename callable_t_>
252 template<
typename callable_t_>
255 template<
typename callable_t_>
282#if HX_CPLUSPLUS >= 202302L
288 template<
typename self_t_,
typename callable_t_>
290 this self_t_&& self_,
hxsize_t index_, callable_t_&& callable_)
291 ->
decltype(self_.end());
297 template<
typename self_t_,
typename callable_t_>
299 this self_t_&& self_,
const T_* it_, callable_t_&& callable_)
300 ->
decltype(self_.end());
331#if HX_CPLUSPLUS >= 202302L
336 template<
typename self_t_,
typename... args_t_>
338 this self_t_&& self_,
hxsize_t index_, args_t_&&... args_);
343 template<
typename self_t_,
typename... args_t_>
345 this self_t_&& self_,
const T_* it_, args_t_&&... args_);
349 void destruct_(T_* begin_, T_* end_)
noexcept;
354template<
typename T_, hx
size_t capacity_>
366template<
typename T_, hx
size_t capacity_>
378template<
typename T_, hx
size_t capacity_>
385#include "detail/hxarray.inl"
const T * data(void) const
Returns a pointer to a const and potentially uninitialized array of T.
Definition hxallocator.hpp:96
hxallocator(void)
Does not allocate until reserve_storage is called.
Definition hxallocator.hpp:78
hxallocator<1+> - Provides static allocation when capacity is greater than zero.
Definition hxallocator.hpp:25
hxarray - Implements std::array with a few things added.
Definition hxarray.hpp:52
auto or_else(this self_t_ &&self_, hxsize_t index_, callable_t_ &&callable_) -> decltype(self_.end())
Returns an iterator to the element at index, or the result of calling callable when the index is outs...
const T * find(const T &value_) const
Finds the first occurrence of value using hxkey_equal.
bool less(const hxarray &x_) const
Returns true if this array compares less than x using hxkey_equal and hxkey_less.
hxarray(void) noexcept
Default constructs all elements.
const T * cbegin(void) const
Returns a const T* to the beginning of the array (alias for begin).
Definition hxarray.hpp:210
hxarray(const T &x_) noexcept
Constructs all elements as copies of x.
bool all_of(callable_t_ &&callable_) const
Returns true if the predicate returns true for every element and false otherwise.
T * find(const T &value_)
auto and_then(this self_t_ &&self_, hxsize_t index_, callable_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< T & >())))>
Returns the result of calling callable with the element at index, otherwise returns hxnil.
auto and_then(this self_t_ &&self_, const T *it_, callable_t_ &&callable_) -> hxremove_cvref_t< decltype(hxforward< callable_t_ >(callable_)(hxforward_like< self_t_ >(hxdeclval< const T & >())))>
Iterator overload of and_then.
void swap(hxarray &x_) noexcept
Swap contents with a temporary array.
hxsize_t size_bytes(void) const
Returns the number of bytes in the array. (Non-standard.).
Definition hxarray.hpp:318
const T * find_if(callable_t_ &&callable_) const
Finds the first element for which the predicate returns true.
~hxarray(void) noexcept
Destructs the array and destroys all elements.
T value_t
value_type - Publishes the value type.
Definition hxarray.hpp:61
const T * binary_search(const T &value_) const
Performs a binary search using hxkey_less.
const T * const_iterator
const_iterator - Const random access iterator.
Definition hxarray.hpp:58
hxsize_t size(void) const
Returns the number of elements in the array.
Definition hxarray.hpp:315
hxsize_t capacity(void) const
Returns the capacity of the array.
T * iterator
iterator - Random access iterator.
Definition hxarray.hpp:55
T value_or(this self_t_ &&self_, hxsize_t index_, args_t_ &&... args_)
Returns a copy of the element at index, or a T constructed from args when the index is outside the ar...
void for_each(callable_t_ &&callable_) const
Calls a function, lambda, or std::function on each element.
T * end(void)
Definition hxarray.hpp:224
hxarray(range_t_ &range_) noexcept
Constructs by copying elements from a range referenced by an lvalue.
const T * begin(void) const
Returns a const T* to the beginning of the array.
Definition hxarray.hpp:195
void insertion_sort(void) noexcept
Sorts the array with insertion sort using hxkey_less.
void memset(int byte_=0x00)
Calls memset on the array.
const T * end(void) const
Returns a const T* to the end of the array.
Definition hxarray.hpp:222
const T * cend(void) const
Returns a const T* to the end of the array.
Definition hxarray.hpp:213
T value_or(this self_t_ &&self_, const T *it_, args_t_ &&... args_)
Iterator overload of value_or.
void sort(void) noexcept
Sorts the array using hxkey_less.
hxarray(hxarray &&x_) noexcept
Move constructs from a temporary hxarray.
bool any_of(callable_t_ &&callable_) const
Returns true if the predicate returns true for any element and false otherwise.
auto or_else(this self_t_ &&self_, const T *it_, callable_t_ &&callable_) -> decltype(self_.end())
Iterator overload of or_else.
bool full(void) const
Returns true if the array has been allocated.
Definition hxarray.hpp:248
T * binary_search(const T &value_)
hxarray(range_t_ &&range_) noexcept
Constructs by moving elements from a temporary range.
bool any_of(callable_t_ &&callable_)
void reserve(hxsize_t size_, hxsystem_allocator_t allocator_=hxsystem_allocator_current, hxalignment_t alignment_=hxalignment) noexcept
Allocates storage for size elements and default constructs them when capacity is hxallocator_dynamic_...
hxsize_t max_size(void) const
Returns the capacity of the array.
Definition hxarray.hpp:272
hxhash_t hash(void) const
Returns a hash mixing the hashes of every element in order using hxkey_hash.
bool empty(void) const
Returns true if the array contains no elements.
Definition hxarray.hpp:219
T * begin(void)
Definition hxarray.hpp:197
hxarray(std::initializer_list< other_value_t_ > x_) noexcept
Pass values of std::initializer_list as initializers.
bool equal(const hxarray &x_) const
Returns true if the arrays compare equivalent using hxkey_equal.
void for_each(callable_t_ &&callable_)
T & operator[](hxsize_t index_)
hxarray(const other_value_t_(&array_)[array_length_]) noexcept
Constructs from a C-style array.
const T & operator[](hxsize_t index_) const
Returns a const reference to the element at the specified index.
void operator=(hxarray &&x_) noexcept
Move assigns from a temporary hxarray.
hxarray(const hxarray &x_) noexcept
Copy constructs from another hxarray of the same capacity.
T * find_if(callable_t_ &&callable_)
void operator=(const other_value_t_(&array_)[array_length_]) noexcept
Assign from a C-style array.
void memcpy(const hxarray &x_)
Copies another hxarray using memcpy.
void operator=(const hxarray &x_) noexcept
Assigns the contents of another hxarray of the same capacity.
bool all_of(callable_t_ &&callable_)
bool operator()(const hxarray< T, capacity_ > &x_, const hxarray< T, capacity_ > &y_) const
Definition hxarray.hpp:358
hxkey_equal_t<T> - A constexpr callable that returns true if two objects are equivalent.
Definition hxkey.hpp:57
hxhash_t operator()(const hxarray< T, capacity_ > &x_) const
Definition hxarray.hpp:382
hxkey_hash_t<T> - A callable that returns the xxhash32 of a numeric value cast to 32 bits.
Definition hxkey.hpp:146
bool operator()(const hxarray< T, capacity_ > &x_, const hxarray< T, capacity_ > &y_) const
Definition hxarray.hpp:370
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.
Implements or includes std::initializer_list depending on HX_USE_LIBCXX.
@ 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 hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:125
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:98
#define hxattr_flatten
hxattr_flatten - Inline every call inside a function's body into it, recursively, regardless of the c...
Definition hxsettings.h:90
Standard sorting utilities.
constexpr bool hxis_same(void)
hxis_same<A, B> - Implements std::is_same.
Definition hxutility.h:246
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
constexpr bool hxis_lvalue_reference(void)
hxis_lvalue_reference<T> - Implements std::is_lvalue_reference.
Definition hxutility.h:207
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.
constexpr hxsize_t hxsizeof(void)
hxsizeof - Returns the size of a type or expression as hxsize_t.
Definition libhatchet.h:294
uint32_t hxhash_t
hxhash_t - Unsigned 32-bit hash value. Expect collisions.
Definition libhatchet.h:210
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:207