LvArray
Classes | Functions
LvArray::bufferManipulation Namespace Reference

Contains template functions for performing common operations on buffers. More...

Classes

class  VoidBuffer
 This class implements the default behavior for the Buffer methods related to execution space. This class is not intended to be used directly, instead derive from it if you would like to inherit the default behavior. More...
 

Functions

 HAS_MEMBER_FUNCTION_NO_RTYPE (move, MemorySpace::host, true)
 Defines a static constexpr bool HasMemberFunction_move< CLASS > that is true iff the class has a method move(MemorySpace, bool). More...
 
template<typename BUFFER >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void check (BUFFER const &buf, std::ptrdiff_t const size)
 Check that given Buffer and size are valid. More...
 
template<typename BUFFER >
void checkInsert (BUFFER const &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos)
 Check that given Buffer, size, and insertion position, are valid. More...
 
template<typename BUFFER >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void free (BUFFER &buf, std::ptrdiff_t const size)
 Destroy the values in the buffer and free it's memory. More...
 
template<typename BUFFER >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void setCapacity (BUFFER &buf, std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity)
 Set the capacity of the buffer. More...
 
template<typename BUFFER >
LVARRAY_HOST_DEVICE void reserve (BUFFER &buf, std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity)
 Reserve space in the buffer for at least the given capacity. More...
 
template<typename BUFFER >
void dynamicReserve (BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const newCapacity)
 If the buffer's capacity is greater than newCapacity this is a no-op. Otherwise the buffer's capacity is increased to at least 2 * newCapacity. More...
 
template<typename BUFFER , typename ... ARGS>
LVARRAY_HOST_DEVICE void resize (BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const newSize, ARGS &&... args)
 Resize the buffer to the given size. More...
 
template<typename BUFFER , typename ... ARGS>
void emplaceBack (BUFFER &buf, std::ptrdiff_t const size, ARGS &&... args)
 Construct a new value at the end of the buffer. More...
 
template<typename BUFFER , typename ... ARGS>
void emplace (BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos, ARGS &&... args)
 Construct a new value at position pos. More...
 
template<typename BUFFER , typename ITER >
std::ptrdiff_t insert (BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos, ITER const first, ITER const last)
 Insert multiple values into the buffer. More...
 
template<typename BUFFER >
void popBack (BUFFER &buf, std::ptrdiff_t const size)
 Remove a value from the end of the buffer. More...
 
template<typename BUFFER >
void erase (BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos)
 Erase a value from the buffer. More...
 
template<typename DST_BUFFER , typename SRC_BUFFER >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void copyInto (DST_BUFFER &dst, std::ptrdiff_t const dstSize, SRC_BUFFER const &src, std::ptrdiff_t const srcSize)
 Copy values from the source buffer into the destination buffer. More...
 

Detailed Description

Contains template functions for performing common operations on buffers.

Each function accepts a buffer and a size as the first two arguments.

Function Documentation

◆ check()

template<typename BUFFER >
LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK void LvArray::bufferManipulation::check ( BUFFER const &  buf,
std::ptrdiff_t const  size 
)
inline

Check that given Buffer and size are valid.

Template Parameters
BUFFERthe buffer type.
Parameters
bufThe buffer to check.
sizeThe size of the buffer.
Note
This method is a no-op when LVARRAY_BOUNDS_CHECK is not defined.

◆ checkInsert()

template<typename BUFFER >
void LvArray::bufferManipulation::checkInsert ( BUFFER const &  buf,
std::ptrdiff_t const  size,
std::ptrdiff_t const  pos 
)
inline

Check that given Buffer, size, and insertion position, are valid.

Template Parameters
BUFFERthe buffer type.
Parameters
bufThe buffer to check.
sizeThe size of the buffer.
posThe insertion position.
Note
This method is a no-op when LVARRAY_BOUNDS_CHECK is not defined.

◆ copyInto()

template<typename DST_BUFFER , typename SRC_BUFFER >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::bufferManipulation::copyInto ( DST_BUFFER &  dst,
std::ptrdiff_t const  dstSize,
SRC_BUFFER const &  src,
std::ptrdiff_t const  srcSize 
)

Copy values from the source buffer into the destination buffer.

Template Parameters
DST_BUFFERthe destination buffer type.
SRC_BUFFERthe source buffer type.
Parameters
dstThe destination buffer.
dstSizeThe size of the destination buffer.
srcThe source buffer.
srcSizeThe size of the source buffer.

◆ dynamicReserve()

template<typename BUFFER >
void LvArray::bufferManipulation::dynamicReserve ( BUFFER &  buf,
std::ptrdiff_t const  size,
std::ptrdiff_t const  newCapacity 
)

If the buffer's capacity is greater than newCapacity this is a no-op. Otherwise the buffer's capacity is increased to at least 2 * newCapacity.

Template Parameters
BUFFERthe buffer type.
Parameters
bufThe buffer to reserve space in.
sizeThe size of the buffer.
newCapacityThe new minimum capacity of the buffer.
Note
Use this in methods which increase the size of the buffer to efficiently grow the capacity.

◆ emplace()

template<typename BUFFER , typename ... ARGS>
void LvArray::bufferManipulation::emplace ( BUFFER &  buf,
std::ptrdiff_t const  size,
std::ptrdiff_t const  pos,
ARGS &&...  args 
)

Construct a new value at position pos.

Template Parameters
BUFFERThe buffer type.
ARGSA variadic pack of argument types.
Parameters
bufThe buffer to insert into.
sizeThe current size of the buffer.
posThe position to construct the values at.
argsA variadic pack of parameters to construct the new value with.

◆ emplaceBack()

template<typename BUFFER , typename ... ARGS>
void LvArray::bufferManipulation::emplaceBack ( BUFFER &  buf,
std::ptrdiff_t const  size,
ARGS &&...  args 
)

Construct a new value at the end of the buffer.

Template Parameters
BUFFERThe buffer type.
ARGSA variadic pack of argument types.
Parameters
bufThe buffer to insert into.
sizeThe current size of the buffer.
argsA variadic pack of parameters to construct the new value with.

◆ erase()

template<typename BUFFER >
void LvArray::bufferManipulation::erase ( BUFFER &  buf,
std::ptrdiff_t const  size,
std::ptrdiff_t const  pos 
)

Erase a value from the buffer.

Template Parameters
BUFFERthe buffer type.
Parameters
bufThe buffer to erase from.
sizeThe current size of the buffer.
posThe position to erase.

◆ free()

template<typename BUFFER >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::bufferManipulation::free ( BUFFER &  buf,
std::ptrdiff_t const  size 
)

Destroy the values in the buffer and free it's memory.

Template Parameters
BUFFERthe buffer type.
Parameters
bufThe buffer to free.
sizeThe size of the buffer.

◆ HAS_MEMBER_FUNCTION_NO_RTYPE()

LvArray::bufferManipulation::HAS_MEMBER_FUNCTION_NO_RTYPE ( move  ,
MemorySpace::host  ,
true   
)

Defines a static constexpr bool HasMemberFunction_move< CLASS > that is true iff the class has a method move(MemorySpace, bool).

Template Parameters
CLASSThe type to test.

◆ insert()

template<typename BUFFER , typename ITER >
std::ptrdiff_t LvArray::bufferManipulation::insert ( BUFFER &  buf,
std::ptrdiff_t const  size,
std::ptrdiff_t const  pos,
ITER const  first,
ITER const  last 
)

Insert multiple values into the buffer.

Template Parameters
BUFFERThe buffer type.
ITERAn iterator type.
Parameters
bufThe buffer to insert into.
sizeThe current size of the buffer.
posThe position to insert the values at.
firstAn iterator to the first value to insert.
lastAn iterator to the end of the values to insert.
Returns
The number of values inserted.

◆ popBack()

template<typename BUFFER >
void LvArray::bufferManipulation::popBack ( BUFFER &  buf,
std::ptrdiff_t const  size 
)

Remove a value from the end of the buffer.

Template Parameters
BUFFERthe buffer type.
Parameters
bufThe buffer to remove from.
sizeThe current size of the buffer.

◆ reserve()

template<typename BUFFER >
LVARRAY_HOST_DEVICE void LvArray::bufferManipulation::reserve ( BUFFER &  buf,
std::ptrdiff_t const  size,
MemorySpace const  space,
std::ptrdiff_t const  newCapacity 
)

Reserve space in the buffer for at least the given capacity.

Template Parameters
BUFFERthe buffer type.
Parameters
bufThe buffer to reserve space in.
sizeThe size of the buffer.
spaceThe space to perform the reserve in.
newCapacityThe new minimum capacity of the buffer.

◆ resize()

template<typename BUFFER , typename ... ARGS>
LVARRAY_HOST_DEVICE void LvArray::bufferManipulation::resize ( BUFFER &  buf,
std::ptrdiff_t const  size,
std::ptrdiff_t const  newSize,
ARGS &&...  args 
)

Resize the buffer to the given size.

Template Parameters
BUFFERthe buffer type.
ARGSThe types of the arguments to initialize the new values with.
Parameters
bufThe buffer to resize.
sizeThe current size of the buffer.
newSizeThe new size of the buffer.
argsThe arguments to initialize the new values with.

◆ setCapacity()

template<typename BUFFER >
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void LvArray::bufferManipulation::setCapacity ( BUFFER &  buf,
std::ptrdiff_t const  size,
MemorySpace const  space,
std::ptrdiff_t const  newCapacity 
)

Set the capacity of the buffer.

Template Parameters
BUFFERthe buffer type.
Parameters
bufThe buffer to set the capacity of.
sizeThe size of the buffer.
spaceThe space to set the capacity in.
newCapacityThe new capacity of the buffer.