AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::sidre::Array< T, DIM > Class Template Reference

Provides a generic multi-component array, contained in Sidre. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.7.0/src/axom/sidre/core/Array.hpp>

Inheritance diagram for axom::sidre::Array< T, DIM >:

Public Types

using value_type = T
 
using ArrayIterator = ArrayIteratorBase< Array< T, DIM, MemorySpace::Dynamic >, T >
 
using ConstArrayIterator = ArrayIteratorBase< const Array< T, DIM, MemorySpace::Dynamic >, const T >
 
using ArrayViewType = ArrayView< T, DIM, MemorySpace::Dynamic >
 
using ConstArrayViewType = ArrayView< const T, DIM, MemorySpace::Dynamic >
 
using RealConstT = typename std::conditional< is_array_view, T, const T >::type
 
using SliceType = typename std::conditional< DIM==IdxDim, T &, typename detail::SubsliceProxy< T, DIM - IdxDim, Array< T, DIM, MemorySpace::Dynamic > >::type >::type
 
using ConstSliceType = typename std::conditional< DIM==IdxDim, RealConstT &, typename detail::SubsliceProxy< T, DIM - IdxDim, const Array< T, DIM, MemorySpace::Dynamic > >::type >::type
 

Public Member Functions

 Array ()=delete
 Default constructor. Disabled. More...
 
 Array (const Array &)=delete
 Copy constructor. More...
 
 Array (Array &&other)
 Move constructor. More...
 
virtual ~Array ()
 
Arrayoperator= (const Array &)=delete
 Copy assignment. More...
 
Arrayoperator= (Array &&other)
 Move assignment. More...
 
Array< T, DIM, MemorySpace::Dynamic >::ArrayIterator emplace (Array< T, DIM, MemorySpace::Dynamic >::ArrayIterator pos, Args &&... args)
 
void swap (ArrayBase &other)
 Swaps two ArrayBases. More...
 
AXOM_HOST_DEVICE SliceType< sizeof...(Args)> operator() (Args... args)
 Dimension-aware accessor; with N=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index. More...
 
AXOM_HOST_DEVICE ConstSliceType< sizeof...(Args)> operator() (Args... args) const
 
AXOM_HOST_DEVICE SliceType< 1 > operator[] (const IndexType idx)
 Scalar accessor; returns a sub-array referenced by the given sub- index, beginning at array(idx, 0...) More...
 
AXOM_HOST_DEVICE ConstSliceType< 1 > operator[] (const IndexType idx) const
 
AXOM_HOST_DEVICE SliceType< UDim > operator[] (const StackArray< IndexType, UDim > &idx)
 Dimension-aware accessor; with UDim=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index. More...
 
AXOM_HOST_DEVICE ConstSliceType< UDim > operator[] (const StackArray< IndexType, UDim > &idx) const
 
AXOM_HOST_DEVICE const StackArray< IndexType, DIM > & shape () const
 Returns the dimensions of the Array. More...
 
AXOM_HOST_DEVICE const StackArray< IndexType, DIM > & strides () const
 Returns the strides of the Array. More...
 
Sidre Array constructors
template<int SFINAE = DIM, typename std::enable_if< SFINAE==1 >::type * = nullptr>
 Array (View *view)
 Creates an Array instance from a View that already has data. More...
 
template<int SFINAE = DIM, typename std::enable_if< SFINAE==2 >::type * = nullptr>
 Array (View *view)
 
template<int SFINAE = DIM, typename std::enable_if< SFINAE==1 >::type * = nullptr>
 Array (View *view, axom::IndexType num_elements, axom::IndexType capacity=0)
 Creates an Array instance of num_elements size and populates the associated View. More...
 
template<int SFINAE = DIM, typename std::enable_if< SFINAE==2 >::type * = nullptr>
 Array (View *view, axom::IndexType num_tuples, axom::IndexType num_components=1, axom::IndexType capacity=0)
 Creates an Array instance of num_tuples size, where each tuple consists of num_components values and populates the associated View. More...
 
Array methods to query and set attributes
virtual bool isExternal () const
 Return true iff the external buffer constructor was called. More...
 
const ViewgetView () const
 Return a pointer to the View that this Array wraps. More...
 
Array element access operators
T * data ()
 Return a pointer to the array of data. More...
 
const T * data () const
 
Array methods to modify the data.
void fill (const T &value)
 Set all the values of the array. More...
 
void set (const T *elements, IndexType n, IndexType pos)
 Modify the values of existing elements. More...
 
void clear ()
 Clears the contents of the array. More...
 
void insert (IndexType pos, const T &value)
 Insert an element into the array at the given position. More...
 
ArrayIterator insert (ArrayIterator pos, const T &value)
 Insert an element into the array at the value before pos. More...
 
void insert (IndexType pos, IndexType n, const T *values)
 Insert elements into the array at the given position. More...
 
ArrayIterator insert (ArrayIterator pos, IndexType n, const T *values)
 Insert elements into the array at the value before pos. More...
 
void insert (IndexType pos, IndexType n, const T &value)
 Insert n copies of element into the array at the given position. More...
 
ArrayIterator insert (ArrayIterator pos, IndexType n, const T &value)
 Insert n copies of element into the array at the value before pos. More...
 
void insert (IndexType pos, ArrayView< const T, DIM, OtherSpace > other)
 Inserts an Array to the end of the calling object. More...
 
void insert (IndexType pos, ArrayView< T, DIM, OtherSpace > other)
 
void append (ArrayView< const T, DIM, OtherSpace > other)
 Appends an Array to the end of the calling object. More...
 
void append (ArrayView< T, DIM, OtherSpace > other)
 
ArrayIterator erase (ArrayIterator pos)
 Erases an element from the Array. More...
 
ArrayIterator erase (ArrayIterator first, ArrayIterator last)
 Erases elements in the range [first, last) from the Array. More...
 
void emplace (IndexType pos, Args &&... args)
 Inserts new element into Array at the given position. More...
 
ArrayIterator emplace (ArrayIterator pos, Args &&... args)
 Inserts new element into Array before pos. More...
 
void push_back (const T &value)
 Push a value to the back of the array. More...
 
void push_back (T &&value)
 Push a value to the back of the array. More...
 
void emplace_back (Args &&... args)
 Inserts new element at the end of the Array. More...
 
Array methods to query and set attributes
IndexType capacity () const
 Return the number of elements allocated for the data array. More...
 
void reserve (IndexType capacity)
 Increase the capacity. Does nothing if the new capacity is less than the current capacity. More...
 
ArrayIterator begin ()
 Returns an ArrayIterator to the first element of the Array. More...
 
ConstArrayIterator begin () const
 
ArrayIterator end ()
 Returns an ArrayIterator to the element following the last element of the Array. More...
 
ConstArrayIterator end () const
 
void shrink ()
 Shrink the capacity to be equal to the size. More...
 
bool empty () const
 Returns true iff the Array stores no elements. More...
 
IndexType size () const
 Return the number of elements stored in the data array. More...
 
void resize (Args... args)
 Update the number of elements stored in the data array. More...
 
void resize (ArrayOptions::Uninitialized, Args... args)
 
void swap (Array< T, DIM, MemorySpace::Dynamic > &other)
 Exchanges the contents of this Array with the other. More...
 
double getResizeRatio () const
 Get the ratio by which the capacity increases upon dynamic resize. More...
 
void setResizeRatio (double ratio)
 Set the ratio by which the capacity increases upon dynamic resize. More...
 
int getAllocatorID () const
 Get the ID for the umpire allocator. More...
 
ArrayViewType view ()
 Returns a view of the array. More...
 
ConstArrayViewType view () const
 
AXOM_HOST_DEVICE T & flatIndex (const IndexType idx)
 Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data. More...
 
AXOM_HOST_DEVICE RealConstTflatIndex (const IndexType idx) const
 

Static Public Attributes

static constexpr double DEFAULT_RESIZE_RATIO
 
static constexpr IndexType MIN_DEFAULT_CAPACITY
 
static constexpr MemorySpace space
 
static constexpr int Dims
 

Protected Member Functions

virtual void updateNumElements (axom::IndexType new_num_elements)
 Update the number of elements. More...
 
virtual void setCapacity (axom::IndexType new_capacity)
 Set the number of elements allocated for the data array. More...
 
virtual void dynamicRealloc (axom::IndexType new_num_elements)
 Reallocates the data array when the size exceeds the capacity. More...
 
void describeView ()
 Applies this Array's type and dimensions to the sidre View. More...
 
axom::IndexType getViewShape (int dim) const
 Given a non-empty View of dimension 2, returns the length of the given dimension. More...
 
void reallocViewData (IndexType new_capacity)
 Allocates space within the Array's View. More...
 
void resize (const StackArray< IndexType, DIM > &dims, bool default_construct)
 Updates the number of elements stored in the data array. More...
 
void initialize (IndexType num_elements, IndexType capacity, bool should_default_construct=true)
 Initialize an Array instance with the given number of elements. More...
 
void initialize_from_other (const T *data, IndexType num_elements, MemorySpace data_space, bool user_provided_allocator)
 Helper function for initializing an Array instance with an existing range of elements. More...
 
T * reserveForInsert (IndexType n, IndexType pos)
 Make space for a subsequent insertion into the array. More...
 
IndexType blockSize () const
 Returns the minimum "chunk size" that should be allocated For example, 2 would be the chunk size of a 2D array whose second dimension is of size 2. This is used when resizing/reallocating; it wouldn't make sense to have a capacity of 3 in the array described above. More...
 
AXOM_HOST_DEVICE void updateStrides ()
 Updates the internal striding information to a row-major format Intended to be called after m_dims is updated. In the future, this class will support different striding schemes (e.g., column-major) and/or user-provided striding. More...
 
void updateShapeOnInsert (const StackArray< IndexType, DIM > &range_shape)
 Updates the internal dimensions and striding based on the insertion of a range of elements. Intended to be called after the insertion of a multidimensional subslice. More...
 

Static Protected Member Functions

template<typename U = T>
static constexpr std::enable_if<!std::is_enum< U >::value, TypeID >::type sidreTypeId ()
 Return the TypeID corresponding to T. This function handles when T is not an enum. More...
 
template<typename U = T>
static constexpr std::enable_if< std::is_enum< U >::value, TypeID >::type sidreTypeId ()
 Return the TypeID corresponding to T. This function handles when T is an enum. More...
 

Protected Attributes

Viewm_view
 
T * m_data
 
IndexType m_num_elements
 The full number of elements in the array i.e., 3 for a 1D Array of size 3, 9 for a 3x3 2D array, etc. More...
 
IndexType m_capacity
 
double m_resize_ratio
 
int m_allocator_id
 
StackArray< IndexType, DIM > m_dims
 The sizes (extents?) in each dimension. More...
 
StackArray< IndexType, DIM > m_strides
 The strides in each dimension. More...
 

Detailed Description

template<typename T, int DIM = 1>
class axom::sidre::Array< T, DIM >

Provides a generic multi-component array, contained in Sidre.

This sidre::Array class extends axom::Array by storing data in a Sidre DataStore. This class provides a generic multi-component array container with dynamic re-allocation and insertion. Each element in the array is a tuple consisting of 1 or more components, which are stored contiguously.

Objects of the sidre::Array class may be constructed from a View. All array operations can be performed as with the base axom::utilities::Array class. The size of the Array can grow as needed, and all memory management is delegated to Sidre.

Note
When the Array object is deleted, it does not delete the associated data in Sidre, since, Sidre owns the data.
Warning
Reallocations tend to be costly operations in terms of performance. Use reserve() when the number of nodes is known a priori, or opt to use a constructor that takes an actual size and capacity when possible.
Template Parameters
Tthe type of the values to hold.
See also
Group
View

Member Typedef Documentation

◆ value_type

using axom::Array< T, DIM, MemorySpace::Dynamic >::value_type = T
inherited

◆ ArrayIterator

◆ ConstArrayIterator

using axom::Array< T, DIM, MemorySpace::Dynamic >::ConstArrayIterator = ArrayIteratorBase<const Array<T, DIM, MemorySpace::Dynamic >, const T>
inherited

◆ ArrayViewType

◆ ConstArrayViewType

using axom::Array< T, DIM, MemorySpace::Dynamic >::ConstArrayViewType = ArrayView<const T, DIM, MemorySpace::Dynamic >
inherited

◆ RealConstT

using axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::RealConstT = typename std::conditional<is_array_view, T, const T>::type
inherited

◆ SliceType

using axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::SliceType = typename std::conditional< DIM == IdxDim, T&, typename detail::SubsliceProxy<T, DIM - IdxDim, Array< T, DIM, MemorySpace::Dynamic > >::type>::type
inherited

◆ ConstSliceType

using axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::ConstSliceType = typename std::conditional< DIM == IdxDim, RealConstT&, typename detail::SubsliceProxy<T, DIM - IdxDim, const Array< T, DIM, MemorySpace::Dynamic > >::type>::type
inherited

Constructor & Destructor Documentation

◆ Array() [1/7]

template<typename T , int DIM = 1>
axom::sidre::Array< T, DIM >::Array ( )
delete

Default constructor. Disabled.

◆ Array() [2/7]

template<typename T , int DIM = 1>
axom::sidre::Array< T, DIM >::Array ( const Array< T, DIM > &  )
delete

Copy constructor.

Deleted because copies would have to reference the same underlying Sidre buffer, which does not match the underlying axom::Array ownership model

◆ Array() [3/7]

template<typename T , int DIM = 1>
axom::sidre::Array< T, DIM >::Array ( Array< T, DIM > &&  other)

Move constructor.

Parameters
[in]otherThe array to move from

◆ Array() [4/7]

template<typename T , int DIM>
template<int SFINAE, typename std::enable_if< SFINAE==2 >::type * >
axom::sidre::Array< T, DIM >::Array ( View view)

Creates an Array instance from a View that already has data.

Parameters
[in]viewthe View that holds this Array's data.
Note
The Sidre view shape has two dimensions. The first dimension corresponds to the max capacity of the array and the second corresponds to the number of components per tuple.
Precondition
view != nullptr
view->isEmpty() == false.
view->getNumDimensions() == 2
Postcondition
capacity() == view->getDimension(0)
numComponents() == view->getDimension(1)
getResizeRatio() == DEFAULT_RESIZE_RATIO

References axom::sidre::Array< T, DIM >::Array(), axom::sidre::View::getBuffer(), axom::sidre::Buffer::getNumElements(), axom::sidre::View::getTypeID(), axom::sidre::Array< T, DIM >::getViewShape(), axom::sidre::View::getVoidPtr(), axom::sidre::View::isEmpty(), axom::Array< T, DIM >::m_capacity, axom::Array< T, DIM >::m_data, axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::m_dims, axom::Array< T, DIM >::m_num_elements, axom::sidre::Array< T, DIM >::m_view, axom::sidre::Array< T, DIM >::sidreTypeId(), SLIC_ERROR_IF, axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::updateStrides(), and axom::Array< T, DIM >::view().

◆ Array() [5/7]

template<typename T , int DIM = 1>
template<int SFINAE = DIM, typename std::enable_if< SFINAE==2 >::type * = nullptr>
axom::sidre::Array< T, DIM >::Array ( View view)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Array() [6/7]

template<typename T , int DIM>
template<int SFINAE, typename std::enable_if< SFINAE==1 >::type * >
axom::sidre::Array< T, DIM >::Array ( View view,
axom::IndexType  num_elements,
axom::IndexType  capacity = 0 
)

Creates an Array instance of num_elements size and populates the associated View.

Parameters
[in]viewthe View that will hold this Array's data.
[in]num_elementsthe number of values.
[in]capacitythe number of values to allocate space for.
Note
The capacity argument is optional. If not specified or if less than num_elements, the capacity of the array will be initialized to num_elements * DEFAULT_RESIZE_RATIO.
The non-null view is expected to be empty and will be populated to hold this Array's data.
The Sidre view shape has one dimension.
Precondition
view != nullptr
view->isEmpty() == true
num_elements >= 1
Postcondition
view->getNumDimensions() == 1
view->isEmpty() == false
size() == num_elements.
numComponents() == num_components
getResizeRatio() == DEFAULT_RESIZE_RATIO

References axom::Array< T, DIM >::capacity(), axom::sidre::View::isEmpty(), axom::Array< T, DIM >::m_capacity, axom::Array< T, DIM >::m_data, axom::Array< T, DIM >::m_num_elements, axom::sidre::Array< T, DIM >::m_view, axom::sidre::Array< T, DIM >::reallocViewData(), SLIC_ASSERT, and SLIC_ERROR_IF.

◆ Array() [7/7]

template<typename T , int DIM>
template<int SFINAE, typename std::enable_if< SFINAE==2 >::type * >
axom::sidre::Array< T, DIM >::Array ( View view,
axom::IndexType  num_tuples,
axom::IndexType  num_components = 1,
axom::IndexType  capacity = 0 
)

Creates an Array instance of num_tuples size, where each tuple consists of num_components values and populates the associated View.

Parameters
[in]viewthe View that will hold this Array's data.
[in]num_tuplesthe number of tuples accounted for in the Array.
[in]num_componentsthe number of values per tuple. If not specified defaults to 1.
[in]capacitythe number of tuples to allocate space for.
Note
The capacity argument is optional. If not specified or if less than num_tuples, the capacity of the Array will be initialized to num_tuples * DEFAULT_RESIZE_RATIO.
The non-null view is expected to be empty and will be populated to hold this Array's data.
The Sidre view shape has two dimensions. The first dimension corresponds to the number of tuples and the second corresponds to the number of components per tuple.
Precondition
view != nullptr
view->isEmpty() == true
num_tuples >= 1
num_components >= 1
Postcondition
view->getNumDimensions() == 2
view->isEmpty() == false
size() == num_tuples.
numComponents() == num_components
getResizeRatio() == DEFAULT_RESIZE_RATIO

References axom::Array< T, DIM >::capacity(), axom::sidre::View::isEmpty(), axom::Array< T, DIM >::m_capacity, axom::Array< T, DIM >::m_data, axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::m_dims, axom::Array< T, DIM >::m_num_elements, axom::sidre::Array< T, DIM >::m_view, axom::sidre::Array< T, DIM >::reallocViewData(), SLIC_ASSERT, SLIC_ERROR_IF, and axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::updateStrides().

◆ ~Array()

template<typename T , int DIM>
axom::sidre::Array< T, DIM >::~Array ( )
virtual

Destructor. Frees the associated buffer unless owned by Sidre.

Reimplemented from axom::Array< T, DIM >.

References axom::Array< T, DIM >::m_data, and axom::sidre::Array< T, DIM >::m_view.

Member Function Documentation

◆ operator=() [1/2]

template<typename T , int DIM = 1>
Array& axom::sidre::Array< T, DIM >::operator= ( const Array< T, DIM > &  )
delete

Copy assignment.

Deleted because copies would have to reference the same underlying Sidre buffer, which does not match the underlying axom::Array ownership model

◆ operator=() [2/2]

template<typename T , int DIM = 1>
Array& axom::sidre::Array< T, DIM >::operator= ( Array< T, DIM > &&  other)

Move assignment.

Parameters
[in]otherThe Array to move from

◆ isExternal()

template<typename T , int DIM = 1>
virtual bool axom::sidre::Array< T, DIM >::isExternal ( ) const
inlinevirtual

Return true iff the external buffer constructor was called.

◆ getView()

template<typename T , int DIM = 1>
const View* axom::sidre::Array< T, DIM >::getView ( ) const
inline

Return a pointer to the View that this Array wraps.

◆ updateNumElements()

template<typename T , int DIM>
void axom::sidre::Array< T, DIM >::updateNumElements ( axom::IndexType  new_num_elements)
inlineprotectedvirtual

Update the number of elements.

Parameters
[in]new_num_elementsthe new number of elements.

Reimplemented from axom::Array< T, DIM >.

References axom::sidre::Array< T, DIM >::describeView(), axom::Array< T, DIM >::m_capacity, axom::Array< T, DIM >::m_num_elements, and SLIC_ASSERT.

◆ setCapacity()

template<typename T , int DIM>
void axom::sidre::Array< T, DIM >::setCapacity ( axom::IndexType  new_capacity)
inlineprotectedvirtual

Set the number of elements allocated for the data array.

Parameters
[in]capacitythe new number of elements to allocate.

Reimplemented from axom::Array< T, DIM >.

References axom::Array< T, DIM >::m_num_elements, axom::sidre::Array< T, DIM >::reallocViewData(), SLIC_ASSERT, and axom::sidre::Array< T, DIM >::updateNumElements().

◆ dynamicRealloc()

template<typename T , int DIM>
void axom::sidre::Array< T, DIM >::dynamicRealloc ( axom::IndexType  new_num_elements)
inlineprotectedvirtual

Reallocates the data array when the size exceeds the capacity.

Parameters
[in]new_num_elementsthe number of elements which exceeds the current capacity.

Reimplemented from axom::Array< T, DIM >.

References axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::blockSize(), axom::Array< T, DIM >::m_resize_ratio, axom::sidre::Array< T, DIM >::reallocViewData(), and SLIC_ERROR_IF.

◆ sidreTypeId() [1/2]

template<typename T , int DIM = 1>
template<typename U = T>
static constexpr std::enable_if<!std::is_enum<U>::value, TypeID>::type axom::sidre::Array< T, DIM >::sidreTypeId ( )
inlinestaticprotected

Return the TypeID corresponding to T. This function handles when T is not an enum.

◆ sidreTypeId() [2/2]

template<typename T , int DIM = 1>
template<typename U = T>
static constexpr std::enable_if<std::is_enum<U>::value, TypeID>::type axom::sidre::Array< T, DIM >::sidreTypeId ( )
inlinestaticprotected

Return the TypeID corresponding to T. This function handles when T is an enum.

◆ describeView()

template<typename T , int DIM>
void axom::sidre::Array< T, DIM >::describeView ( )
inlineprotected

◆ getViewShape()

template<typename T , int DIM>
axom::IndexType axom::sidre::Array< T, DIM >::getViewShape ( int  dim) const
inlineprotected

Given a non-empty View of dimension 2, returns the length of the given dimension.

Parameters
[in]viewthe View to examine.
[in]dimthe dimension (0 or 1) to return the length of.
Precondition
0 <= dim <= 1

References axom::sidre::Array< T, DIM >::m_view.

◆ reallocViewData()

template<typename T , int DIM>
void axom::sidre::Array< T, DIM >::reallocViewData ( IndexType  new_capacity)
inlineprotected

◆ data() [1/2]

T* axom::Array< T, DIM, MemorySpace::Dynamic >::data ( )
inlineinherited

Return a pointer to the array of data.

◆ data() [2/2]

const T* axom::Array< T, DIM, MemorySpace::Dynamic >::data ( ) const
inlineinherited

◆ fill()

void axom::Array< T, DIM, MemorySpace::Dynamic >::fill ( const T &  value)
inlineinherited

Set all the values of the array.

Parameters
[in]valuethe value to set to.

◆ set()

void axom::Array< T, DIM, MemorySpace::Dynamic >::set ( const T *  elements,
IndexType  n,
IndexType  pos 
)
inlineinherited

Modify the values of existing elements.

Parameters
[in]elementsthe new elements to write.
[in]nthe number of elements to write.
[in]posthe position at which to begin writing.
Note
It's assumed that elements is of length n.
The size is unchanged by calls to set.
Precondition
pos + n <= m_num_elements.

◆ clear()

void axom::Array< T, DIM, MemorySpace::Dynamic >::clear ( )
inlineinherited

Clears the contents of the array.

Postcondition
size of Array is 0
capacity is unchanged

◆ insert() [1/8]

void axom::Array< T, DIM, MemorySpace::Dynamic >::insert ( IndexType  pos,
const T &  value 
)
inlineinherited

Insert an element into the array at the given position.

Parameters
[in]posthe position at which to insert.
[in]valuethe element value to insert.
Note
Reallocation is done if the new size will exceed the capacity.
The size increases by 1.

◆ insert() [2/8]

ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::insert ( ArrayIterator  pos,
const T &  value 
)
inherited

Insert an element into the array at the value before pos.

Parameters
[in]posthe ArrayIterator before which value will be inserted.
[in]valuethe element value to insert.
Note
Reallocation is done if the new size will exceed the capacity.
The size increases by 1.
Returns
ArrayIterator to inserted value

◆ insert() [3/8]

void axom::Array< T, DIM, MemorySpace::Dynamic >::insert ( IndexType  pos,
IndexType  n,
const T *  values 
)
inlineinherited

Insert elements into the array at the given position.

Parameters
[in]posthe position at which to begin the insertion.
[in]nthe number of elements to insert.
[in]valuesthe element values to insert.
Note
It's assumed that elements is of length n.
Reallocation is done if the new size will exceed the capacity.
The size increases by n.
Precondition
pos <= m_num_elements.

◆ insert() [4/8]

ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::insert ( ArrayIterator  pos,
IndexType  n,
const T *  values 
)
inherited

Insert elements into the array at the value before pos.

Parameters
[in]posthe ArrayIterator before which value will be inserted.
[in]nthe number of elements to insert.
[in]valuesthe element values to insert.
Note
It's assumed that elements is of length n.
Reallocation is done if the new size will exceed the capacity.
The size increases by n.
Precondition
pos <= end()
Returns
ArrayIterator to first element inserted (pos if n == 0)

◆ insert() [5/8]

void axom::Array< T, DIM, MemorySpace::Dynamic >::insert ( IndexType  pos,
IndexType  n,
const T &  value 
)
inlineinherited

Insert n copies of element into the array at the given position.

Parameters
[in]posthe position at which to begin the insertion.
[in]nthe number of elements to insert.
[in]valuethe element value to insert.
Note
Reallocation is done if the new size will exceed the capacity.
The size increases by n.
This method is used to create space for elements in the middle of the array.
Precondition
pos <= m_num_elements.

◆ insert() [6/8]

ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::insert ( ArrayIterator  pos,
IndexType  n,
const T &  value 
)
inherited

Insert n copies of element into the array at the value before pos.

Parameters
[in]posthe ArrayIterator before which value will be inserted.
[in]nthe number of elements to insert.
[in]valuethe element value to insert.
Note
Reallocation is done if the new size will exceed the capacity.
The size increases by n.
This method is used to create space for elements in the middle of the array.
Precondition
pos <= end()
Returns
ArrayIterator to first element inserted (pos if n == 0)

◆ insert() [7/8]

void axom::Array< T, DIM, MemorySpace::Dynamic >::insert ( IndexType  pos,
ArrayView< const T, DIM, OtherSpace >  other 
)
inlineinherited

Inserts an Array to the end of the calling object.

Parameters
[in]otherThe Array to append
Precondition
The shapes of the calling Array and other are the same (excluding the leading dimension), i.e., shape()[1:] == other.shape()[1:]
Note
Reallocation is done if the new size will exceed the capacity.

◆ insert() [8/8]

void axom::Array< T, DIM, MemorySpace::Dynamic >::insert ( IndexType  pos,
ArrayView< T, DIM, OtherSpace >  other 
)
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ append() [1/2]

void axom::Array< T, DIM, MemorySpace::Dynamic >::append ( ArrayView< const T, DIM, OtherSpace >  other)
inlineinherited

Appends an Array to the end of the calling object.

Parameters
[in]otherThe Array to append
Template Parameters
OtherArrayTypeThe underlying type of the other array
Note
Reallocation is done if the new size will exceed the capacity.

◆ append() [2/2]

void axom::Array< T, DIM, MemorySpace::Dynamic >::append ( ArrayView< T, DIM, OtherSpace >  other)
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ erase() [1/2]

ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::erase ( ArrayIterator  pos)
inherited

Erases an element from the Array.

Parameters
[in]posthe ArrayIterator to the element in the Array
Returns
An ArrayIterator following the last element removed.

◆ erase() [2/2]

ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::erase ( ArrayIterator  first,
ArrayIterator  last 
)
inherited

Erases elements in the range [first, last) from the Array.

Parameters
[in]firstthe ArrayIterator to the beginning of the range.
[in]lastthe ArrayIterator to end of range.
Returns
An ArrayIterator following the last element removed.

◆ emplace() [1/3]

void axom::Array< T, DIM, MemorySpace::Dynamic >::emplace ( IndexType  pos,
Args &&...  args 
)
inlineinherited

Inserts new element into Array at the given position.

Parameters
[in]posthe position to insert element at.
[in]argsthe arguments to forward to constructor of the element.
Note
Reallocation is done if the new size will exceed the capacity.
The size increases by 1.
Precondition
T must be MoveAssignable

◆ emplace() [2/3]

ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::emplace ( ArrayIterator  pos,
Args &&...  args 
)
inherited

Inserts new element into Array before pos.

Parameters
[in]posthe ArrayIterator to insert element before.
[in]argsthe arguments to forward to constructor of the element.
Note
Reallocation is done if the new size will exceed the capacity.
The size increases by 1.
Precondition
T must be MoveAssignable
Returns
An ArrayIterator to the emplaced element.

◆ emplace() [3/3]

Array<T, DIM, MemorySpace::Dynamic >::ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::emplace ( Array< T, DIM, MemorySpace::Dynamic >::ArrayIterator  pos,
Args &&...  args 
)
inlineinherited

◆ push_back() [1/2]

void axom::Array< T, DIM, MemorySpace::Dynamic >::push_back ( const T &  value)
inlineinherited

Push a value to the back of the array.

Parameters
[in]valuethe value to be added to the back.
Note
Reallocation is done if the new size will exceed the capacity.
Precondition
DIM == 1

◆ push_back() [2/2]

void axom::Array< T, DIM, MemorySpace::Dynamic >::push_back ( T &&  value)
inlineinherited

Push a value to the back of the array.

Parameters
[in]valuethe value to move to the back.
Note
Reallocation is done if the new size will exceed the capacity.
Precondition
DIM == 1

◆ emplace_back()

void axom::Array< T, DIM, MemorySpace::Dynamic >::emplace_back ( Args &&...  args)
inlineinherited

Inserts new element at the end of the Array.

Parameters
[in]argsthe arguments to forward to constructor of the element.
Note
Reallocation is done if the new size will exceed the capacity.
The size increases by 1.
Precondition
DIM == 1

◆ capacity()

IndexType axom::Array< T, DIM, MemorySpace::Dynamic >::capacity ( ) const
inlineinherited

Return the number of elements allocated for the data array.

◆ reserve()

void axom::Array< T, DIM, MemorySpace::Dynamic >::reserve ( IndexType  capacity)
inlineinherited

Increase the capacity. Does nothing if the new capacity is less than the current capacity.

Parameters
[in]capacitythe new number of elements to allocate.

◆ begin() [1/2]

ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::begin ( )
inlineinherited

Returns an ArrayIterator to the first element of the Array.

◆ begin() [2/2]

ConstArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::begin ( ) const
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ end() [1/2]

ArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::end ( )
inlineinherited

Returns an ArrayIterator to the element following the last element of the Array.

◆ end() [2/2]

ConstArrayIterator axom::Array< T, DIM, MemorySpace::Dynamic >::end ( ) const
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ shrink()

void axom::Array< T, DIM, MemorySpace::Dynamic >::shrink ( )
inlineinherited

Shrink the capacity to be equal to the size.

◆ empty()

bool axom::Array< T, DIM, MemorySpace::Dynamic >::empty ( ) const
inlineinherited

Returns true iff the Array stores no elements.

Note
If the Array is empty the capacity can still be greater than zero.

◆ size()

IndexType axom::Array< T, DIM, MemorySpace::Dynamic >::size ( ) const
inlineinherited

Return the number of elements stored in the data array.

◆ resize() [1/3]

void axom::Array< T, DIM, MemorySpace::Dynamic >::resize ( Args...  args)
inlineinherited

Update the number of elements stored in the data array.

Note
Reallocation is done if the new size will exceed the capacity.

◆ resize() [2/3]

void axom::Array< T, DIM, MemorySpace::Dynamic >::resize ( ArrayOptions::Uninitialized  ,
Args...  args 
)
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ resize() [3/3]

void axom::Array< T, DIM, MemorySpace::Dynamic >::resize ( const StackArray< IndexType, DIM > &  dims,
bool  default_construct 
)
inlineprotectedinherited

Updates the number of elements stored in the data array.

Parameters
[in]dimsthe number of elements to allocate in each dimension
[in]default_constructif true, default-constructs any new elements in the array

◆ swap() [1/2]

void axom::Array< T, DIM, MemorySpace::Dynamic >::swap ( Array< T, DIM, MemorySpace::Dynamic > &  other)
inlineinherited

Exchanges the contents of this Array with the other.

◆ swap() [2/2]

void axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::swap ( ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > > &  other)
inlineinherited

Swaps two ArrayBases.

◆ getResizeRatio()

double axom::Array< T, DIM, MemorySpace::Dynamic >::getResizeRatio ( ) const
inlineinherited

Get the ratio by which the capacity increases upon dynamic resize.

◆ setResizeRatio()

void axom::Array< T, DIM, MemorySpace::Dynamic >::setResizeRatio ( double  ratio)
inlineinherited

Set the ratio by which the capacity increases upon dynamic resize.

Parameters
[in]ratiothe new resize ratio.

◆ getAllocatorID()

int axom::Array< T, DIM, MemorySpace::Dynamic >::getAllocatorID ( ) const
inlineinherited

Get the ID for the umpire allocator.

◆ view() [1/2]

ArrayViewType axom::Array< T, DIM, MemorySpace::Dynamic >::view ( )
inlineinherited

Returns a view of the array.

See also
ArrayView

◆ view() [2/2]

ConstArrayViewType axom::Array< T, DIM, MemorySpace::Dynamic >::view ( ) const
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ initialize()

void axom::Array< T, DIM, MemorySpace::Dynamic >::initialize ( IndexType  num_elements,
IndexType  capacity,
bool  should_default_construct = true 
)
inlineprotectedinherited

Initialize an Array instance with the given number of elements.

Parameters
[in]num_elementsthe number of elements the Array holds.
[in]capacitythe number of elements to allocate space for.
[in]should_default_constructwhether to create default-constructed objects in the region [0, num_elements). Defaults to true.
Note
If no capacity or capacity less than num_elements is specified then it will default to at least num_elements * DEFAULT_RESIZE_RATIO.
a capacity is specified for the number of elements to store in the array and does not correspond to the actual bytesize.
Precondition
num_elements >= 0
Postcondition
capacity() >= size()
size() == num_elements
getResizeRatio() == DEFAULT_RESIZE_RATIO

◆ initialize_from_other()

void axom::Array< T, DIM, MemorySpace::Dynamic >::initialize_from_other ( const T *  data,
IndexType  num_elements,
MemorySpace  data_space,
bool  user_provided_allocator 
)
inlineprotectedinherited

Helper function for initializing an Array instance with an existing range of elements.

Parameters
[in]datapointer to the existing array of elements
[in]num_elementsthe number of elements in the existing array
[in]data_spacethe memory space in which data has been allocated
[in]user_provided_allocatortrue if the Array's allocator ID was provided by the user

◆ reserveForInsert()

T * axom::Array< T, DIM, MemorySpace::Dynamic >::reserveForInsert ( IndexType  n,
IndexType  pos 
)
inlineprotectedinherited

Make space for a subsequent insertion into the array.

Parameters
[in]nthe number of elements to insert.
[in]posthe position at which to begin the insertion.
Returns
a pointer to the beginning of the insertion space.
Note
Reallocation is done if the new size will exceed the capacity.

◆ operator()() [1/2]

AXOM_HOST_DEVICE SliceType<sizeof...(Args)> axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::operator() ( Args...  args)
inlineinherited

Dimension-aware accessor; with N=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index.

Parameters
[in]argsthe parameter pack of indices in each dimension.
Note
equivalent to *(array.data() + idx).
Precondition
sizeof...(Args) <= DIM
0 <= args[i] < m_dims[i] for i in [0, sizeof...(Args))

◆ operator()() [2/2]

AXOM_HOST_DEVICE ConstSliceType<sizeof...(Args)> axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::operator() ( Args...  args) const
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator[]() [1/4]

AXOM_HOST_DEVICE SliceType<1> axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::operator[] ( const IndexType  idx)
inlineinherited

Scalar accessor; returns a sub-array referenced by the given sub- index, beginning at array(idx, 0...)

Parameters
[in]idxthe index of the first dimension.
Precondition
0 <= idx < m_dims[0]

◆ operator[]() [2/4]

AXOM_HOST_DEVICE ConstSliceType<1> axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::operator[] ( const IndexType  idx) const
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator[]() [3/4]

AXOM_HOST_DEVICE SliceType<UDim> axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::operator[] ( const StackArray< IndexType, UDim > &  idx)
inlineinherited

Dimension-aware accessor; with UDim=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index.

Parameters
[in]argsa stack array of indices in each dimension.
Note
equivalent to *(array.data() + idx).
Precondition
UDim <= DIM
0 <= args[i] < m_dims[i] for i in [0, UDim)

◆ operator[]() [4/4]

AXOM_HOST_DEVICE ConstSliceType<UDim> axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::operator[] ( const StackArray< IndexType, UDim > &  idx) const
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ flatIndex() [1/2]

AXOM_HOST_DEVICE T& axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::flatIndex ( const IndexType  idx)
inlineinherited

Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data.

Parameters
[in]idxthe position of the value to return.
Note
equivalent to *(array.data() + idx).
Precondition
0 <= idx < m_num_elements

◆ flatIndex() [2/2]

AXOM_HOST_DEVICE RealConstT& axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::flatIndex ( const IndexType  idx) const
inlineinherited

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ shape()

AXOM_HOST_DEVICE const StackArray<IndexType, DIM>& axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::shape ( ) const
inlineinherited

Returns the dimensions of the Array.

◆ strides()

AXOM_HOST_DEVICE const StackArray<IndexType, DIM>& axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::strides ( ) const
inlineinherited

Returns the strides of the Array.

◆ blockSize()

IndexType axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::blockSize ( ) const
inlineprotectedinherited

Returns the minimum "chunk size" that should be allocated For example, 2 would be the chunk size of a 2D array whose second dimension is of size 2. This is used when resizing/reallocating; it wouldn't make sense to have a capacity of 3 in the array described above.

◆ updateStrides()

AXOM_HOST_DEVICE void axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::updateStrides ( )
inlineprotectedinherited

Updates the internal striding information to a row-major format Intended to be called after m_dims is updated. In the future, this class will support different striding schemes (e.g., column-major) and/or user-provided striding.

◆ updateShapeOnInsert()

void axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::updateShapeOnInsert ( const StackArray< IndexType, DIM > &  range_shape)
inlineprotectedinherited

Updates the internal dimensions and striding based on the insertion of a range of elements. Intended to be called after the insertion of a multidimensional subslice.

Member Data Documentation

◆ m_view

template<typename T , int DIM = 1>
View* axom::sidre::Array< T, DIM >::m_view
protected

◆ DEFAULT_RESIZE_RATIO

constexpr double axom::Array< T, DIM, MemorySpace::Dynamic >::DEFAULT_RESIZE_RATIO
staticinherited

◆ MIN_DEFAULT_CAPACITY

constexpr IndexType axom::Array< T, DIM, MemorySpace::Dynamic >::MIN_DEFAULT_CAPACITY
staticinherited

◆ space

constexpr MemorySpace axom::Array< T, DIM, MemorySpace::Dynamic >::space
staticinherited

◆ m_data

T* axom::Array< T, DIM, MemorySpace::Dynamic >::m_data
protectedinherited

◆ m_num_elements

IndexType axom::Array< T, DIM, MemorySpace::Dynamic >::m_num_elements
protectedinherited

The full number of elements in the array i.e., 3 for a 1D Array of size 3, 9 for a 3x3 2D array, etc.

◆ m_capacity

IndexType axom::Array< T, DIM, MemorySpace::Dynamic >::m_capacity
protectedinherited

◆ m_resize_ratio

double axom::Array< T, DIM, MemorySpace::Dynamic >::m_resize_ratio
protectedinherited

◆ m_allocator_id

int axom::Array< T, DIM, MemorySpace::Dynamic >::m_allocator_id
protectedinherited

◆ Dims

constexpr int axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::Dims
staticinherited

◆ m_dims

StackArray<IndexType, DIM> axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::m_dims
protectedinherited

The sizes (extents?) in each dimension.

◆ m_strides

StackArray<IndexType, DIM> axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::m_strides
protectedinherited

The strides in each dimension.


The documentation for this class was generated from the following file: