LvArray
Functions
LvArray::arrayManipulation Namespace Reference

Contains functions for operating on a contiguous array of values. More...

Functions

template<typename INDEX_TYPE >
LVARRAY_HOST_DEVICE constexpr std::enable_if< std::is_signed< INDEX_TYPE >::value, bool >::type isPositive (INDEX_TYPE const i)
 
template<typename INDEX_TYPE >
LVARRAY_HOST_DEVICE constexpr std::enable_if< !std::is_signed< INDEX_TYPE >::value, bool >::type isPositive (INDEX_TYPE)
 
template<typename ITER >
DISABLE_HD_WARNING constexpr LVARRAY_HOST_DEVICE std::iterator_traits< ITER >::difference_type iterDistance (ITER first, ITER const last, std::input_iterator_tag)
 
template<typename RandomAccessIterator >
DISABLE_HD_WARNING constexpr LVARRAY_HOST_DEVICE std::iterator_traits< RandomAccessIterator >::difference_type iterDistance (RandomAccessIterator first, RandomAccessIterator last, std::random_access_iterator_tag)
 
template<typename ITER >
DISABLE_HD_WARNING constexpr LVARRAY_HOST_DEVICE std::iterator_traits< ITER >::difference_type iterDistance (ITER const first, ITER const last)
 
template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void destroy (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size)
 Destory the values in the array. More...
 
template<typename ITER , typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void uninitializedCopy (ITER first, ITER const &last, T *LVARRAY_RESTRICT dst)
 Copy construct values from the source to the destination. More...
 
template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void uninitializedMove (T *const LVARRAY_RESTRICT dst, std::ptrdiff_t const size, T *const LVARRAY_RESTRICT src)
 Move construct values from the source to the destination. More...
 
template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void uninitializedShiftDown (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const amount)
 Shift values down into uninitialized memory. More...
 
template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void uninitializedShiftUp (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const amount)
 Shift values up into uninitialized memory. More...
 
template<typename T , typename ... ARGS>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void resize (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const newSize, ARGS &&... args)
 Resize the give array. More...
 
template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void shiftUp (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, std::ptrdiff_t const n)
 Shift the values in the array at or above the given position up by the given amount. New uninitialized values take their place. More...
 
template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void shiftDown (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, std::ptrdiff_t const n)
 Shift the values in the array at or above the given position down by the given amount overwriting the existing values. The n entries at the end of the array are not destroyed. More...
 
template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void erase (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, std::ptrdiff_t const n=1)
 Shift the values in the array at or above the given position down by the given amount overwriting the existing values. The n entries at the end of the array are then destroyed. More...
 
template<typename T , typename ... ARGS>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void emplaceBack (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, ARGS &&... args)
 Append the to the array constructing the new value in place. More...
 
template<typename T , typename ITER >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE std::ptrdiff_t append (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, ITER first, ITER const last)
 Append the given values to the array. More...
 
template<typename T , typename ... ARGS>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void emplace (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, ARGS &&... args)
 Insert into the array constructing the new value in place. More...
 
template<typename T , typename ITERATOR >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void insert (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const index, ITERATOR first, std::ptrdiff_t const n)
 Insert the given values into the array at the given position. More...
 
template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void popBack (T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size)
 Destroy the value at the end of the array. More...
 

Detailed Description

Contains functions for operating on a contiguous array of values.

Most functions accept a pointer and a size as the first two arguments. Values in this range are expected to be in a valid state. Values past the end of the array are expected to be uninitialized. Functions that increase the size of the array expect the array to have a large enough capacity to handle the increase.

Function Documentation

◆ append()

template<typename T , typename ITER >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE std::ptrdiff_t LvArray::arrayManipulation::append ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
ITER  first,
ITER const  last 
)
inline

Append the given values to the array.

Template Parameters
TThe storage type of the array.
ITERThe type of the iterators first and last.
Parameters
ptrPointer to the array.
sizeThe size of the array.
firstAn iterator to the first value to append.
lastAn iterator to the end of the values to append.
Returns
The number of values appended.

◆ destroy()

template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::destroy ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size 
)
inline

Destory the values in the array.

Template Parameters
Tthe storage type of the array.
Parameters
ptrPointer to the array.
sizeThe size of the array.

◆ emplace()

template<typename T , typename ... ARGS>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::emplace ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
std::ptrdiff_t const  index,
ARGS &&...  args 
)
inline

Insert into the array constructing the new value in place.

Template Parameters
TThe storage type of the array.
ARGSVariadic pack of types to construct T with, the types of args.
Parameters
ptrPointer to the array.
sizeThe size of the array.
indexThe position to insert at.
argsThe arguments to forward to construct the new value.

◆ emplaceBack()

template<typename T , typename ... ARGS>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::emplaceBack ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
ARGS &&...  args 
)
inline

Append the to the array constructing the new value in place.

Template Parameters
TThe storage type of the array.
ARGSVariadic pack of types to construct T with, the types of args.
Parameters
ptrPointer to the array.
sizeThe size of the array.
argsThe arguments to forward to construct the new value.

◆ erase()

template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::erase ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
std::ptrdiff_t const  index,
std::ptrdiff_t const  n = 1 
)
inline

Shift the values in the array at or above the given position down by the given amount overwriting the existing values. The n entries at the end of the array are then destroyed.

Template Parameters
Tthe storage type of the array.
Parameters
ptrPointer to the array.
sizeThe size of the array.
indexthe index at which to begin the shift.
nthe number of places to shift.

◆ insert()

template<typename T , typename ITERATOR >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::insert ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
std::ptrdiff_t const  index,
ITERATOR  first,
std::ptrdiff_t const  n 
)
inline

Insert the given values into the array at the given position.

Template Parameters
TThe storage type of the array.
ITERATORAn iterator type, the type of first.
Parameters
ptrPointer to the array.
sizeThe size of the array.
indexThe position to insert the value at.
firstIterator to the first value to insert.
nThe number of values to insert.

◆ isPositive() [1/2]

template<typename INDEX_TYPE >
LVARRAY_HOST_DEVICE constexpr std::enable_if< std::is_signed< INDEX_TYPE >::value, bool >::type LvArray::arrayManipulation::isPositive ( INDEX_TYPE const  i)
inline
Template Parameters
INDEX_TYPEthe integral type to check.
Returns
Return true iff i is greater than or equal to zero.
Parameters
ithe value to check.

◆ isPositive() [2/2]

template<typename INDEX_TYPE >
LVARRAY_HOST_DEVICE constexpr std::enable_if< !std::is_signed< INDEX_TYPE >::value, bool >::type LvArray::arrayManipulation::isPositive ( INDEX_TYPE  )
inline
Template Parameters
INDEX_TYPEthe integral type to check.
Returns
Returns true. This specialization for unsigned types avoids compiler warnings.

◆ iterDistance() [1/3]

template<typename ITER >
DISABLE_HD_WARNING constexpr LVARRAY_HOST_DEVICE std::iterator_traits< ITER >::difference_type LvArray::arrayManipulation::iterDistance ( ITER  first,
ITER const  last,
std::input_iterator_tag   
)
inline
Template Parameters
ITERAn iterator type.
Returns
The distance between two non-random access iterators.
Parameters
firstThe iterator to the beginning of the range.
lastThe iterator to the end of the range.

◆ iterDistance() [2/3]

template<typename RandomAccessIterator >
DISABLE_HD_WARNING constexpr LVARRAY_HOST_DEVICE std::iterator_traits< RandomAccessIterator >::difference_type LvArray::arrayManipulation::iterDistance ( RandomAccessIterator  first,
RandomAccessIterator  last,
std::random_access_iterator_tag   
)
inline
Template Parameters
ITERAn iterator type.
Returns
The distance between two random access iterators.
Parameters
firstThe iterator to the beginning of the range.
lastThe iterator to the end of the range.

◆ iterDistance() [3/3]

template<typename ITER >
DISABLE_HD_WARNING constexpr LVARRAY_HOST_DEVICE std::iterator_traits< ITER >::difference_type LvArray::arrayManipulation::iterDistance ( ITER const  first,
ITER const  last 
)
inline
Template Parameters
ITERAn iterator type.
Returns
The distance between two iterators.
Parameters
firstThe iterator to the beginning of the range.
lastThe iterator to the end of the range.

◆ popBack()

template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::popBack ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size 
)
inline

Destroy the value at the end of the array.

Template Parameters
Tthe storage type of the array.
Parameters
ptrPointer to the array.
sizeThe size of the array.

◆ resize()

template<typename T , typename ... ARGS>
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::resize ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
std::ptrdiff_t const  newSize,
ARGS &&...  args 
)
inline

Resize the give array.

Template Parameters
Tthe storage type of the array.
ARGSthe types of the arguments to forward to the constructor.
Parameters
ptrPointer to the array.
sizeThe size of the array.
newSizethe new size.
argsthe arguments to forward to construct any new elements with.

◆ shiftDown()

template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::shiftDown ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
std::ptrdiff_t const  index,
std::ptrdiff_t const  n 
)
inline

Shift the values in the array at or above the given position down by the given amount overwriting the existing values. The n entries at the end of the array are not destroyed.

Template Parameters
Tthe storage type of the array.
Parameters
ptrPointer to the array.
sizeThe size of the array.
indexthe index at which to begin the shift.
nthe number of places to shift.

◆ shiftUp()

template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::shiftUp ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
std::ptrdiff_t const  index,
std::ptrdiff_t const  n 
)
inline

Shift the values in the array at or above the given position up by the given amount. New uninitialized values take their place.

Template Parameters
Tthe storage type of the array.
Parameters
ptrPointer to the array.
sizeThe size of the array.
indexthe index at which to begin the shift.
nthe number of places to shift.

◆ uninitializedCopy()

template<typename ITER , typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::uninitializedCopy ( ITER  first,
ITER const &  last,
T *LVARRAY_RESTRICT  dst 
)
inline

Copy construct values from the source to the destination.

Template Parameters
ITERAn iterator type.
Tthe storage type of the array.
Parameters
firstIterator to the first value to copy.
lastIterator to the end of the values to copy.
dstPointer to the destination array, must be uninitialized memory.

◆ uninitializedMove()

template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::uninitializedMove ( T *const LVARRAY_RESTRICT  dst,
std::ptrdiff_t const  size,
T *const LVARRAY_RESTRICT  src 
)
inline

Move construct values from the source to the destination.

Template Parameters
Tthe storage type of the array.
Parameters
dstpointer to the destination array, must be uninitialized memory.
sizeThe number of values to copy.
srcpointer to the source array.

◆ uninitializedShiftDown()

template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::uninitializedShiftDown ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
std::ptrdiff_t const  amount 
)
inline

Shift values down into uninitialized memory.

Template Parameters
Tthe storage type of the array.
Parameters
ptrPointer to the begining of the shift, values before this must be uninitialized.
sizenumber of values to shift.
amountthe amount to shift by.

◆ uninitializedShiftUp()

template<typename T >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::arrayManipulation::uninitializedShiftUp ( T *const LVARRAY_RESTRICT  ptr,
std::ptrdiff_t const  size,
std::ptrdiff_t const  amount 
)
inline

Shift values up into uninitialized memory.

Template Parameters
Tthe storage type of the array.
Parameters
ptrPointer to the begining of the shift.
sizenumber of values to shift, values after this must be uninitialized.
amountthe amount to shift by.