12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
22#if HX_CPLUSPLUS >= 202002L
34#define hxarray_concept_ typename
53template<hxarray_concept_ T_, hx
size_t capacity_=hxallocator_dynamic_capacity>
88 template<
typename other_value_t_, hx
size_t array_length_>
89 hxarray(
const other_value_t_(&array_)[array_length_])
noexcept;
93 template<
typename other_value_t_>
94 hxarray(std::initializer_list<other_value_t_> x_)
noexcept;
106 template<
typename other_value_t_, hx
size_t array_length_>
107 void operator=(
const other_value_t_(&array_)[array_length_])
noexcept;
126 template<
typename callable_t_>
130 template<
typename callable_t_>
142 template<
typename callable_t_>
146 template<
typename callable_t_>
153 template<
typename iter_t_>
154 void assign(iter_t_ begin_, iter_t_ end_)
noexcept;
156#if HX_CPLUSPLUS >= 202002L
161 template<
typename range_t_>
167 template<
typename range_t_>
223 template<
typename callable_t_>
227 template<
typename callable_t_>
232 template<
typename callable_t_>
236 template<
typename callable_t_>
288 void destruct_(T_* begin_, T_* end_)
noexcept;
292#if HX_CPLUSPLUS >= 202002L
296template<
typename T_, hx
size_t capacity_>
305template<
typename T_, hx
size_t capacity_>
321#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:54
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:192
hxarray(const T &x_) noexcept
Constructs all elements as copies of x.
void assign(iter_t_ begin_, iter_t_ end_) noexcept
Assigns elements from a range defined by random access iterators.
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_)
Non-const version of find using hxkey_equal.
void assign_range(range_t_ &range_) noexcept
Assigns elements from a range referenced by an lvalue.
hxsize_t size_bytes(void) const
Returns the number of bytes in the array. (Non-standard.).
Definition hxarray.hpp:282
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.
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:60
hxsize_t size(void) const
Returns the number of elements in the array.
Definition hxarray.hpp:279
hxsize_t capacity(void) const
Returns the capacity of the array.
T * iterator
iterator - Random access iterator.
Definition hxarray.hpp:57
void for_each(callable_t_ &&callable_) const
Calls a function, lambda, or std::function on each element.
T * end(void)
Returns a T* to the end of the array.
Definition hxarray.hpp:209
const T * begin(void) const
Returns a const T* to the beginning of the array.
Definition hxarray.hpp:173
void insertion_sort(void) noexcept
Sorts the array with insertion sort using hxkey_less.
T value_type
value_type - Publishes the value type.
Definition hxarray.hpp:64
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:206
const T * cend(void) const
Returns a const T* to the end of the array.
Definition hxarray.hpp:195
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.
T * binary_search(const T &value_)
Non-const version.
bool any_of(callable_t_ &&callable_)
A non-const version of any_of.
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:257
const T * get(hxsize_t index_) const
Returns a const T* to the element at index or hxnull otherwise.
T * begin(void)
Returns a T* to the beginning of the array.
Definition hxarray.hpp:176
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_)
Non-const version of for_each.
T & operator[](hxsize_t index_)
Returns a reference to the element at the specified 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.
hxarray(const hxarray &x_) noexcept
Copy constructs from another hxarray of the same capacity.
T * find_if(callable_t_ &&callable_)
Non-const version of find_if.
T * get(hxsize_t index_)
Returns a T* to the element at index or hxnull otherwise.
void operator=(const other_value_t_(&array_)[array_length_]) noexcept
Assign from a C-style array.
void assign_range(range_t_ &&range_) noexcept
Assigns elements from a temporary range.
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_)
A non-const version of all_of.
hxarray_concept - Concept smoke testing the hxarray element.
Definition hxarray.hpp:29
Similar to std::allocator.
void hxswap(hxarray< T, hxallocator_dynamic_capacity > &x_, hxarray< T, hxallocator_dynamic_capacity > &y_) noexcept
void hxswap(hxarray<T>& x, hxarray<T>& y) - Exchanges the contents of x and y.
Definition hxarray.hpp:315
bool hxkey_less(const hxarray< T, capacity_ > &x_, const hxarray< T, capacity_ > &y_)
bool hxkey_less(hxarray<T, N>& x, hxarray<T, N>& y) - Compares the contents of x and y lexicographica...
Definition hxarray.hpp:306
bool hxkey_equal(const hxarray< T, capacity_ > &x_, const hxarray< T, capacity_ > &y_)
bool hxkey_equal(hxarray<T, N>& x, hxarray<T, N>& y) - Compares the contents of x and y for equivalen...
Definition hxarray.hpp:297
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: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.
constexpr hxsize_t hxsizeof(void)
hxsizeof - Returns the size of a type or expression as hxsize_t.
Definition libhatchet.h:288
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:209
static constexpr bool value
Definition hxutility.h:124