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

Wrapper around common array operations which holds: More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/main/src/axom/mint/utils/ArrayWrapper.hpp>

Inheritance diagram for axom::mint::detail::ArrayWrapper< T, DIM >:

Public Member Functions

 ArrayWrapper ()=default
 Default-constructs an empty ArrayWrapper. More...
 
template<typename ArrayT >
ArrayWrapperoperator= (ArrayT &&arr)
 Assigns the underlying variant with a specific array. More...
 
void push_back (const T &value)
 Pushes a value to the back of the wrapped array. More...
 
void insert (IndexType pos, IndexType n, const T *values)
 Inserts elements into the wrapped array at a position. More...
 
void insert (IndexType index, ArrayView< const T, DIM > span)
 Inserts elements from a view into the wrapped array. More...
 
void append (ArrayView< const T, DIM > span)
 Appends elements from a view to the wrapped array. More...
 
void set (const T *elements, IndexType n, IndexType pos)
 Sets a range of elements in the wrapped array. More...
 
template<typename... Args>
void resize (Args... args)
 Resizes the wrapped array. More...
 
void reserve (IndexType newCapacity)
 Reserves capacity in the wrapped array. More...
 
void shrink ()
 Shrinks the wrapped array's capacity to its size. More...
 
void setResizeRatio (double ratio)
 Sets the resize ratio of the wrapped array. More...
 
double getResizeRatio () const
 Returns the resize ratio used by the wrapped array. More...
 
IndexType size () const
 Returns the number of elements in the wrapped array. More...
 
IndexType capacity () const
 Returns the capacity of the wrapped array. More...
 
bool empty () const
 Returns true if the wrapped array contains no elements. More...
 
T * data ()
 Returns a pointer to the wrapped array's data buffer. More...
 
const T * data () const
 Returns a const pointer to the wrapped array's data buffer. More...
 
T * operator* ()
 Returns a pointer to the wrapped data buffer. More...
 
const T * operator* () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
axom::StackArray< IndexType, DIM > shape () const
 Returns the logical shape of the wrapped array. More...
 
const ArrayVariant & getVariant () const
 Returns the underlying variant object storing the wrapped arrays. More...
 

Detailed Description

template<typename T, int DIM = 1>
class axom::mint::detail::ArrayWrapper< T, DIM >

Wrapper around common array operations which holds:

  • axom::Array if we own the memory
  • sidre::Array if the memory is stored in Sidre
  • mint::utilities::ExternalArray if the memory is externally-owned

Constructor & Destructor Documentation

◆ ArrayWrapper()

template<typename T , int DIM = 1>
axom::mint::detail::ArrayWrapper< T, DIM >::ArrayWrapper ( )
default

Default-constructs an empty ArrayWrapper.

Member Function Documentation

◆ operator=()

template<typename T , int DIM = 1>
template<typename ArrayT >
ArrayWrapper& axom::mint::detail::ArrayWrapper< T, DIM >::operator= ( ArrayT &&  arr)
inline

Assigns the underlying variant with a specific array.

◆ push_back()

template<typename T , int DIM = 1>
void axom::mint::detail::ArrayWrapper< T, DIM >::push_back ( const T &  value)
inline

Pushes a value to the back of the wrapped array.

Parameters
[in]valueThe value to append.
See also
axom::Array::push_back

◆ insert() [1/2]

template<typename T , int DIM = 1>
void axom::mint::detail::ArrayWrapper< T, DIM >::insert ( IndexType  pos,
IndexType  n,
const T *  values 
)
inline

Inserts elements into the wrapped array at a position.

Parameters
[in]posThe position at which to begin insertion.
[in]nThe number of elements to insert.
[in]valuesPointer to the elements to insert; must reference at least n values.
See also
axom::Array::insert

◆ insert() [2/2]

template<typename T , int DIM = 1>
void axom::mint::detail::ArrayWrapper< T, DIM >::insert ( IndexType  index,
ArrayView< const T, DIM >  span 
)
inline

Inserts elements from a view into the wrapped array.

Inserts the contents of span at the given index of the wrapped array.

Parameters
[in]indexThe position at which to begin insertion.
[in]spanView containing the elements to insert.
See also
axom::Array::insert

◆ append()

template<typename T , int DIM = 1>
void axom::mint::detail::ArrayWrapper< T, DIM >::append ( ArrayView< const T, DIM >  span)
inline

Appends elements from a view to the wrapped array.

Elements in span are appended at the end of the wrapped array.

Parameters
[in]spanView containing the elements to append.
See also
axom::Array::append

◆ set()

template<typename T , int DIM = 1>
void axom::mint::detail::ArrayWrapper< T, DIM >::set ( const T *  elements,
IndexType  n,
IndexType  pos 
)
inline

Sets a range of elements in the wrapped array.

Copies n elements from elements into the wrapped array starting at position pos.

Parameters
[in]elementsPointer to the source elements.
[in]nNumber of elements to copy.
[in]posStarting position in the wrapped array.
See also
axom::Array::set

◆ resize()

template<typename T , int DIM = 1>
template<typename... Args>
void axom::mint::detail::ArrayWrapper< T, DIM >::resize ( Args...  args)
inline

Resizes the wrapped array.

Forwards the given size arguments to the underlying array's resize method.

Parameters
[in]argsNew extents for each dimension.
See also
axom::Array::resize

◆ reserve()

template<typename T , int DIM = 1>
void axom::mint::detail::ArrayWrapper< T, DIM >::reserve ( IndexType  newCapacity)
inline

Reserves capacity in the wrapped array.

Ensures that the wrapped array can hold at least newCapacity elements without reallocation.

Parameters
[in]newCapacityThe new capacity in number of elements.
See also
axom::Array::reserve

◆ shrink()

template<typename T , int DIM = 1>
void axom::mint::detail::ArrayWrapper< T, DIM >::shrink ( )
inline

Shrinks the wrapped array's capacity to its size.

See also
axom::Array::shrink

◆ setResizeRatio()

template<typename T , int DIM = 1>
void axom::mint::detail::ArrayWrapper< T, DIM >::setResizeRatio ( double  ratio)
inline

Sets the resize ratio of the wrapped array.

Controls the factor by which capacity grows when the wrapped array is reallocated.

Parameters
[in]ratioNew resize ratio.
See also
axom::Array::setResizeRatio

◆ getResizeRatio()

template<typename T , int DIM = 1>
double axom::mint::detail::ArrayWrapper< T, DIM >::getResizeRatio ( ) const
inline

Returns the resize ratio used by the wrapped array.

See also
axom::Array::getResizeRatio

◆ size()

template<typename T , int DIM = 1>
IndexType axom::mint::detail::ArrayWrapper< T, DIM >::size ( ) const
inline

Returns the number of elements in the wrapped array.

See also
axom::Array::size

◆ capacity()

template<typename T , int DIM = 1>
IndexType axom::mint::detail::ArrayWrapper< T, DIM >::capacity ( ) const
inline

Returns the capacity of the wrapped array.

See also
axom::Array::capacity

◆ empty()

template<typename T , int DIM = 1>
bool axom::mint::detail::ArrayWrapper< T, DIM >::empty ( ) const
inline

Returns true if the wrapped array contains no elements.

See also
axom::Array::empty

◆ data() [1/2]

template<typename T , int DIM = 1>
T* axom::mint::detail::ArrayWrapper< T, DIM >::data ( )
inline

Returns a pointer to the wrapped array's data buffer.

See also
axom::Array::data

◆ data() [2/2]

template<typename T , int DIM = 1>
const T* axom::mint::detail::ArrayWrapper< T, DIM >::data ( ) const
inline

Returns a const pointer to the wrapped array's data buffer.

See also
axom::Array::data

◆ operator*() [1/2]

template<typename T , int DIM = 1>
T* axom::mint::detail::ArrayWrapper< T, DIM >::operator* ( )
inline

Returns a pointer to the wrapped data buffer.

Equivalent to calling data().

See also
axom::Array::data

References axom::mint::detail::ArrayWrapper< T, DIM >::data().

◆ operator*() [2/2]

template<typename T , int DIM = 1>
const T* axom::mint::detail::ArrayWrapper< T, DIM >::operator* ( ) const
inline

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

References axom::mint::detail::ArrayWrapper< T, DIM >::data().

◆ shape()

template<typename T , int DIM = 1>
axom::StackArray<IndexType, DIM> axom::mint::detail::ArrayWrapper< T, DIM >::shape ( ) const
inline

Returns the logical shape of the wrapped array.

See also
axom::Array::shape

◆ getVariant()

template<typename T , int DIM = 1>
const ArrayVariant& axom::mint::detail::ArrayWrapper< T, DIM >::getVariant ( ) const
inline

Returns the underlying variant object storing the wrapped arrays.


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