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.6.1/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 > >
 

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...
 
void insert (IndexType pos, const ArrayBase< T, DIM, OtherArrayType > &other)
 Appends an Array to the end of the calling object. More...
 
Array< T, DIM, MemorySpace::Dynamic >::ArrayIterator emplace (Array< T, DIM, MemorySpace::Dynamic >::ArrayIterator pos, Args &&... args)
 
AXOM_HOST_DEVICE T & operator() (Args... args)
 Dimension-aware accessor, returns a reference to the given value. More...
 
AXOM_HOST_DEVICE const T & operator() (Args... args) 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 append (const ArrayBase< T, DIM, OtherArrayType > &other)
 Appends an Array to the end of the calling object. More...
 
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...
 
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...
 
ArrayIterator end ()
 Returns an ArrayIterator to the element following the last element of the Array. More...
 
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 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...
 
AXOM_HOST_DEVICE T & operator[] (const IndexType idx)
 Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data. More...
 
AXOM_HOST_DEVICE const T & operator[] (const IndexType idx) const
 

Static Public Attributes

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

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 initialize (IndexType num_elements, IndexType capacity)
 Initialize an Array instance with the given number 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...
 
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...
 

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

Constructor & Destructor Documentation

◆ Array() [1/7]

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

Default constructor. Disabled.

Referenced by axom::sidre::Array< T, DIM >::Array().

◆ 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, and axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::updateStrides().

◆ 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.

Referenced by axom::sidre::Array< T, DIM >::setCapacity().

◆ 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.

Referenced by axom::sidre::Array< T, DIM >::Array(), axom::sidre::Array< T, DIM >::describeView(), and axom::sidre::Array< T, DIM >::reallocViewData().

◆ 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.

Referenced by axom::sidre::Array< T, DIM >::Array().

◆ reallocViewData()

◆ data() [1/2]

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

Return a pointer to the array of data.

References axom::Array< T, DIM, SPACE >::m_data.

◆ data() [2/2]

◆ 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/7]

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/7]

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/7]

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/7]

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/7]

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/7]

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/7]

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

Appends 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.

References axom::StackArray< T, N >::begin(), axom::StackArray< T, N >::end(), axom::ArrayBase< T, DIM, ArrayType >::m_dims, axom::utilities::processAbort(), axom::ArrayBase< T, DIM, ArrayType >::shape(), and axom::ArrayBase< T, DIM, ArrayType >::updateStrides().

◆ append()

void axom::Array< T, DIM, MemorySpace::Dynamic >::append ( const ArrayBase< T, DIM, OtherArrayType > &  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.

References axom::Array< T, DIM, SPACE >::emplace(), axom::Array< T, DIM, SPACE >::erase(), axom::Array< T, DIM, SPACE >::insert(), and axom::Array< T, DIM, SPACE >::size().

◆ 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

◆ capacity()

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

Return the number of elements allocated for the data array.

References axom::Array< T, DIM, SPACE >::m_capacity.

Referenced by axom::sidre::Array< T, DIM >::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.

References axom::Array< T, DIM, SPACE >::m_capacity, and axom::Array< T, DIM, SPACE >::setCapacity().

◆ begin()

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

Returns an ArrayIterator to the first element of the Array.

References axom::Array< T, DIM, SPACE >::m_data.

◆ end()

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

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

References axom::Array< T, DIM, SPACE >::m_data, and axom::Array< T, DIM, SPACE >::size().

◆ shrink()

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

Shrink the capacity to be equal to the size.

References axom::Array< T, DIM, SPACE >::m_num_elements, and axom::Array< T, DIM, SPACE >::setCapacity().

◆ 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.

References axom::Array< T, DIM, SPACE >::m_num_elements.

◆ size()

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

◆ resize()

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.

References axom::detail::allNonNegative(), and axom::detail::packProduct().

◆ swap()

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

◆ getResizeRatio()

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

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

References axom::Array< T, DIM, SPACE >::m_resize_ratio.

◆ 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.

References axom::Array< T, DIM, SPACE >::m_resize_ratio.

◆ getAllocatorID()

◆ initialize()

void axom::Array< T, DIM, MemorySpace::Dynamic >::initialize ( IndexType  num_elements,
IndexType  capacity 
)
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.
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

◆ 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 T& axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::operator() ( Args...  args)
inlineinherited

Dimension-aware accessor, returns a reference to the given value.

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, DIM)

References axom::StackArray< T, N >::begin(), axom::numerics::dot_product(), and axom::ArrayBase< T, DIM, ArrayType >::m_strides.

◆ operator()() [2/2]

AXOM_HOST_DEVICE const T& 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.

References axom::StackArray< T, N >::begin(), axom::numerics::dot_product(), and axom::ArrayBase< T, DIM, ArrayType >::m_strides.

◆ operator[]() [1/2]

AXOM_HOST_DEVICE T& axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::operator[] ( 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

◆ operator[]() [2/2]

AXOM_HOST_DEVICE const T& 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.

◆ 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.

References axom::ArrayBase< T, DIM, ArrayType >::m_dims.

Referenced by axom::sidre::Array< T, DIM >::describeView().

◆ 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.

References axom::ArrayBase< T, DIM, ArrayType >::m_strides.

◆ 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.

References axom::ArrayBase< T, DIM, ArrayType >::m_strides.

Referenced by axom::sidre::Array< T, DIM >::dynamicRealloc().

◆ updateStrides()

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.

References AXOM_HOST_DEVICE, axom::ArrayBase< T, DIM, ArrayType >::m_dims, and axom::ArrayBase< T, DIM, ArrayType >::m_strides.

Referenced by axom::sidre::Array< T, DIM >::Array().

Member Data Documentation

◆ m_view

◆ 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

◆ 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.

Referenced by axom::sidre::Array< T, DIM >::Array(), axom::sidre::Array< T, DIM >::setCapacity(), and axom::sidre::Array< T, DIM >::updateNumElements().

◆ m_capacity

◆ 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

◆ m_dims

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

The sizes (extents?) in each dimension.

Referenced by axom::sidre::Array< T, DIM >::Array().

◆ 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: