array
C++ library for multi-dimensional arrays
|
#include <array.h>
Public Types | |
using | allocator_type = Alloc |
using | alloc_traits = std::allocator_traits< Alloc > |
using | value_type = T |
using | reference = value_type & |
using | const_reference = const value_type & |
using | pointer = typename alloc_traits::pointer |
using | const_pointer = typename alloc_traits::const_pointer |
using | shape_type = Shape |
using | index_type = typename Shape::index_type |
using | shape_traits_type = shape_traits< Shape > |
using | copy_shape_traits_type = copy_shape_traits< Shape, Shape > |
using | size_type = size_t |
Public Member Functions | |
array () | |
array (const Alloc &alloc) | |
array (const Shape &shape, const T &value, const Alloc &alloc) | |
array (const Shape &shape, const T &value) | |
array (const Shape &shape, const Alloc &alloc) | |
array (const Shape &shape) | |
array (const array &other) | |
array (const array &other, const Alloc &alloc) | |
array (array &&other) | |
array (array &&other, const Alloc &alloc) | |
array & | operator= (const array &other) |
array & | operator= (array &&other) |
void | assign (const array &other) |
void | assign (array &&other) |
void | assign (Shape shape, const T &value) |
const Alloc & | get_allocator () const |
reference | operator[] (const index_type &indices) |
const_reference | operator[] (const index_type &indices) const |
template<class... Args, class = enable_if_all_indices<Args...>> | |
reference | operator() (Args...indices) |
template<class... Args, class = enable_if_all_indices<Args...>> | |
const_reference | operator() (Args...indices) const |
template<class... Args, class = enable_if_any_slices<Args...>> | |
auto | operator[] (const std::tuple< Args... > &args) |
template<class... Args, class = enable_if_any_slices<Args...>> | |
auto | operator() (Args...args) |
template<class... Args, class = enable_if_any_slices<Args...>> | |
auto | operator[] (const std::tuple< Args... > &args) const |
template<class... Args, class = enable_if_any_slices<Args...>> | |
auto | operator() (Args...args) const |
template<class Fn , class = internal::enable_if_callable<Fn, reference>> | |
void | for_each_value (Fn &&fn) |
template<class Fn , class = internal::enable_if_callable<Fn, const_reference>> | |
void | for_each_value (Fn &&fn) const |
pointer | base () |
const_pointer | base () const |
pointer | data () |
const_pointer | data () const |
const Shape & | shape () const |
template<size_t D, class = enable_if_dim<D>> | |
const auto & | dim () const |
const nda::dim | dim (size_t d) const |
size_type | size () const |
bool | empty () const |
bool | is_compact () const |
void | clear () |
void | reshape (Shape new_shape) |
void | set_shape (const Shape &new_shape, index_t offset=0) |
const auto & | i () const |
const auto & | j () const |
const auto & | k () const |
const auto & | x () const |
const auto & | y () const |
const auto & | z () const |
const auto & | c () const |
const auto & | w () const |
index_t | width () const |
index_t | height () const |
index_t | channels () const |
index_t | rows () const |
index_t | columns () const |
bool | operator!= (const array &other) const |
bool | operator== (const array &other) const |
void | swap (array &other) |
array_ref< T, Shape > | ref () |
const_array_ref< T, Shape > | cref () const |
const_array_ref< T, Shape > | ref () const |
operator array_ref< T, Shape > () | |
operator const_array_ref< T, Shape > () const | |
template<std::size_t R = rank(), typename = std::enable_if_t<R == 0>> | |
operator reference () | |
template<std::size_t R = rank(), typename = std::enable_if_t<R == 0>> | |
operator const_reference () const | |
Static Public Member Functions | |
static constexpr size_t | rank () |
static constexpr bool | is_scalar () |
Friends | |
template<typename NewShape , typename T2 , typename OldShape , typename Alloc2 > | |
array< T2, NewShape, Alloc2 > | move_reinterpret_shape (array< T2, OldShape, Alloc2 > &&from, const NewShape &new_shape, index_t offset) |
template<typename NewShape , typename T2 , typename OldShape , typename Alloc2 > | |
array< T2, NewShape, Alloc2 > | move_reinterpret_shape (array< T2, OldShape, Alloc2 > &&from, index_t offset) |
A multi-dimensional array container that owns an allocation of memory.
using allocator_type = Alloc |
Type of the allocator used to allocate memory in this array.
using value_type = T |
Type of the values stored in this array.
using shape_type = Shape |
Type of the shape of this array.
|
inline |
Construct an array with a default constructed Shape. Most shapes are empty by default, but a Shape with non-zero compile-time constants for all extents will be non-empty.
|
inline |
Construct an array with a particular shape
, allocated by alloc
. All elements in the array are copy-constructed from value
.
|
inlineexplicit |
Construct an array with a particular shape
, allocated by alloc
, with default constructed elements.
Copy construct from another array other
, using copy's allocator. This is a deep copy of the contents of other
.
Copy construct from another array other
. The array is allocated using alloc
. This is a deep copy of the contents of other
.
Move construct from another array other
. If the allocator of this array is propagate_on_container_move_assignment or the allocators of both arrays are equal this operation moves the allocation of other to this array, and the other array becomes a default constructed array. Otherwise, each element is move-constructed into a new allocation.
Move construct from another array other
. If the allocator of this array and the other array are equal, this operation moves the allocation of other to this array, and the other array becomes a default constructed array. If the allocator of this and the other array are non-equal, each element is move-constructed into a new allocation.
|
inlinestatic |
The number of dims in the shape of this array.
|
inlinestatic |
True if the rank of this array is 0.
Assign the contents of the array as a copy of other
. The array is deallocated if the allocator cannot be propagated on assignment. The array is then reallocated if necessary, and each element in the array is copy constructed from other.
Assign the contents of the array by moving from other
. If the allocator can be propagated on move assignment, the allocation of other
is moved in an O(1) operation. If the allocator cannot be propagated, each element is move-assigned from other
.
|
inline |
Assign the contents of the array to be a copy or move of other
. The array is destroyed, reallocated if necessary, and then each element is copy- or move-constructed from other
.
|
inline |
Assign the contents of this array to have shape
with each element copy constructed from value
.
|
inline |
Get the allocator used to allocate memory for this buffer.
|
inline |
Get a reference to the element at indices
.
|
inline |
Create an array_ref
from this array using indices or intervals args
. Dimensions corresponding to indices in args
are sliced, i.e. the result will not have this dimension. The rest of the dimensions are cropped.
|
inline |
Call a function with a reference to each value in this array. The order in which fn
is called is undefined to enable optimized memory accesses.
|
inline |
Pointer to the element at the min index of the shape.
|
inline |
Pointer to the element at the beginning of the flat array. This is equivalent to base()
if all of the strides of the shape are positive.
|
inline |
Shape of this array.
|
inline |
Reset the shape of this array to default. If the default constructed Shape
is empty, the array will be empty. If the default constructed Shape
is non-empty, the elements of the array will be default constructed.
|
inline |
Reallocate the array, and move the intersection of the old and new shapes to the new array.
|
inline |
Change the shape of the array to new_shape
, and move the base pointer by offset
. This function is disabled for non-trivial types, because it does not call the destructor or constructor for newly inaccessible or newly accessible elements, respectively.
|
inline |
Provide some aliases for common interpretations of dimensions i
, j
, k
as dimensions 0, 1, 2, respectively.
|
inline |
Provide some aliases for common interpretations of dimensions x
, y
, z
or c
, w
as dimensions 0, 1, 2, 3 respectively.
|
inline |
Assuming this array represents an image with dimensions width, height, channels, get the extent of those dimensions.
|
inline |
Assuming this array represents a matrix with dimensions {rows, cols}, get the extent of those dimensions.
|
inline |
Compare the contents of this array to other
. For two arrays to be considered equal, they must have the same shape, and all elements addressable by the shape must also be equal.
|
inline |
Swap the contents of two arrays. This performs zero copies or moves of individual elements.
|
inline |
Implicit conversion to T
for scalar shaped arrays.