|
libhatchet
|
#include <hxarray.hpp>
Public Types | |
| using | iterator = T* |
| using | const_iterator = const T* |
| using | value_type = T |
Public Member Functions | |
| hxarray (void) noexcept | |
| hxarray (const T &x_) noexcept | |
| hxarray (const hxarray &x_) noexcept | |
| hxarray (hxarray &&x_) noexcept | |
| template<typename other_value_t_, hxsize_t array_length_> | |
| hxarray (const other_value_t_(&array_)[array_length_]) noexcept | |
| template<typename other_value_t_> | |
| hxarray (std::initializer_list< other_value_t_ > x_) noexcept | |
| ~hxarray (void) noexcept | |
| void | operator= (const hxarray &x_) noexcept |
| template<typename other_value_t_, hxsize_t array_length_> | |
| void | operator= (const other_value_t_(&array_)[array_length_]) noexcept |
| const T & | operator[] (hxsize_t index_) const |
| T & | operator[] (hxsize_t index_) |
| template<typename callable_t_> | |
| bool | all_of (callable_t_ &&callable_) const |
| template<typename callable_t_> | |
| bool | all_of (callable_t_ &&callable_) |
| template<typename callable_t_> | |
| bool | any_of (callable_t_ &&callable_) const |
| template<typename callable_t_> | |
| bool | any_of (callable_t_ &&callable_) |
| template<typename iter_t_> | |
| void | assign (iter_t_ begin_, iter_t_ end_) noexcept |
| template<typename range_t_> | |
| void | assign_range (range_t_ &range_) noexcept |
| template<typename range_t_> requires (!hxis_lvalue_reference<range_t_>::value) | |
| void | assign_range (range_t_ &&range_) noexcept |
| const T * | begin (void) const |
| T * | begin (void) |
| const T * | binary_search (const T &value_) const |
| T * | binary_search (const T &value_) |
| hxsize_t | capacity (void) const |
| const T * | cbegin (void) const |
| const T * | cend (void) const |
| bool | equal (const hxarray &x_) const |
| const T * | end (void) const |
| T * | end (void) |
| const T * | find (const T &value_) const |
| T * | find (const T &value_) |
| template<typename callable_t_> | |
| const T * | find_if (callable_t_ &&callable_) const |
| template<typename callable_t_> | |
| T * | find_if (callable_t_ &&callable_) |
| template<typename callable_t_> | |
| void | for_each (callable_t_ &&callable_) const |
| template<typename callable_t_> | |
| void | for_each (callable_t_ &&callable_) |
| const T * | get (hxsize_t index_) const |
| T * | get (hxsize_t index_) |
| void | insertion_sort (void) noexcept |
| bool | less (const hxarray &x_) const |
| hxsize_t | max_size (void) const |
| void | memcpy (const hxarray &x_) |
| void | memset (int byte_=0x00) |
| void | reserve (hxsize_t size_, hxsystem_allocator_t allocator_=hxsystem_allocator_current, hxalignment_t alignment_=hxalignment) noexcept |
| hxsize_t | size (void) const |
| hxsize_t | size_bytes (void) const |
| void | sort (void) noexcept |
hxarray - Implements std::array with a few things added.
It also implements a dynamically allocated array that does not change size using hxallocator_dynamic_capacity which provides an optimization the standard does not. Uses raw pointers as an iterator type so that you get compile errors and debug symbols that use plain C++ pointers instead. There are exhaustive asserts. hxarray uses the hxkey_less and hxkey_equal overloads. They default to using operators < and ==. See hxalgorithm.hpp for callable versions of the algorithms here.
Unlike hxvector, hxarray always has a fixed size equal to its capacity. Size-changing operations are not provided. Use hxvector when dynamic sizing is needed. When capacity is hxallocator_dynamic_capacity, storage must be allocated by calling reserve before use.
| using hxarray< T, capacity_ >::const_iterator = const T* |
const_iterator - Const random access iterator.
| using hxarray< T, capacity_ >::iterator = T* |
iterator - Random access iterator.
| using hxarray< T, capacity_ >::value_type = T |
value_type - Publishes the value type.
Doesn't end with _t because of the standard.
|
explicitnoexcept |
Default constructs all elements.
|
explicitnoexcept |
Constructs all elements as copies of x.
|
noexcept |
|
noexcept |
Move constructs from a temporary hxarray.
Requires hxallocator_dynamic_capacity.
|
noexcept |
Constructs from a C-style array.
e.g.,
|
noexcept |
Pass values of std::initializer_list as initializers.
|
noexcept |
Destructs the array and destroys all elements.
| bool hxarray< T, capacity_ >::all_of | ( | callable_t_ && | callable_ | ) |
A non-const version of all_of.
| bool hxarray< T, capacity_ >::all_of | ( | callable_t_ && | callable_ | ) | const |
Returns true if the predicate returns true for every element and false otherwise.
Will stop iterating when the predicate returns false. e.g.,
| bool hxarray< T, capacity_ >::any_of | ( | callable_t_ && | callable_ | ) |
A non-const version of any_of.
| bool hxarray< T, capacity_ >::any_of | ( | callable_t_ && | callable_ | ) | const |
Returns true if the predicate returns true for any element and false otherwise.
Will stop iterating when the predicate returns true. e.g.,
|
noexcept |
|
noexcept |
Assigns elements from a temporary range.
This overload enables moving the range elements into the array when forwarding rvalues.
|
noexcept |
Assigns elements from a range referenced by an lvalue.
range_t::begin and range_t::end are required. Use operator= to assign from a C-style array.
|
inline |
Returns a T* to the beginning of the array.
|
inline |
Returns a const T* to the beginning of the array.
| T * hxarray< T, capacity_ >::binary_search | ( | const T & | value_ | ) |
Non-const version.
Performs a binary search using hxkey_less. Returns end() when not found.
| const T * hxarray< T, capacity_ >::binary_search | ( | const T & | value_ | ) | const |
Performs a binary search using hxkey_less.
Returns end() when not found.
| hxsize_t hxarray< T, capacity_ >::capacity | ( | void | ) | const |
Returns the capacity of the array.
|
inline |
Returns a const T* to the beginning of the array (alias for begin).
|
inline |
Returns a const T* to the end of the array.
|
inline |
Returns a T* to the end of the array.
|
inline |
Returns a const T* to the end of the array.
| bool hxarray< T, capacity_ >::equal | ( | const hxarray< T, capacity_ > & | x_ | ) | const |
Returns true if the arrays compare equivalent using hxkey_equal.
Callers must check the return value to detect mismatches.
| T * hxarray< T, capacity_ >::find | ( | const T & | value_ | ) |
Non-const version of find using hxkey_equal.
| const T * hxarray< T, capacity_ >::find | ( | const T & | value_ | ) | const |
Finds the first occurrence of value using hxkey_equal.
Returns end() if no element matches.
| T * hxarray< T, capacity_ >::find_if | ( | callable_t_ && | callable_ | ) |
Non-const version of find_if.
| const T * hxarray< T, capacity_ >::find_if | ( | callable_t_ && | callable_ | ) | const |
Finds the first element for which the predicate returns true.
Returns end() if no element matches.
| void hxarray< T, capacity_ >::for_each | ( | callable_t_ && | callable_ | ) |
Non-const version of for_each.
| void hxarray< T, capacity_ >::for_each | ( | callable_t_ && | callable_ | ) | const |
Calls a function, lambda, or std::function on each element.
| T * hxarray< T, capacity_ >::get | ( | hxsize_t | index_ | ) |
Returns a T* to the element at index or hxnull otherwise.
| const T * hxarray< T, capacity_ >::get | ( | hxsize_t | index_ | ) | const |
Returns a const T* to the element at index or hxnull otherwise.
|
noexcept |
Sorts the array with insertion sort using hxkey_less.
| bool hxarray< T, capacity_ >::less | ( | const hxarray< T, capacity_ > & | x_ | ) | const |
Returns true if this array compares less than x using hxkey_equal and hxkey_less.
Callers must check the return value to observe the ordering result.
|
inline |
Returns the capacity of the array.
| void hxarray< T, capacity_ >::memcpy | ( | const hxarray< T, capacity_ > & | x_ | ) |
| void hxarray< T, capacity_ >::memset | ( | int | byte_ = 0x00 | ) |
Calls memset on the array.
The default fill byte is 0x00.
|
noexcept |
|
noexcept |
Assign from a C-style array.
The array length must equal the capacity of this array.
| T & hxarray< T, capacity_ >::operator[] | ( | hxsize_t | index_ | ) |
Returns a reference to the element at the specified index.
| const T & hxarray< T, capacity_ >::operator[] | ( | hxsize_t | index_ | ) | const |
Returns a const reference to the element at the specified index.
|
noexcept |
Allocates storage for size elements and default constructs them when capacity is hxallocator_dynamic_capacity.
The current capacity becomes size elements. Reallocation is not allowed. When capacity is fixed, size must equal capacity.
|
inline |
Returns the number of elements in the array.
|
inline |
Returns the number of bytes in the array. (Non-standard.).
|
noexcept |
Sorts the array using hxkey_less.