GEOSX
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 >
constexpr 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 >
void free (BUFFER &buf, std::ptrdiff_t const size)
 Destroy the values in the buffer and free it's memory. More...
 
template<typename BUFFER >
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 >
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>
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 >
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 >
constexpr void LvArray::bufferManipulation::check ( BUFFER const &  buf,
std::ptrdiff_t const  size 
)
inlineconstexpr

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.

Definition at line 144 of file bufferManipulation.hpp.

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

Definition at line 166 of file bufferManipulation.hpp.

◆ copyInto()

template<typename DST_BUFFER , typename SRC_BUFFER >
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.

Definition at line 393 of file bufferManipulation.hpp.

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

Definition at line 251 of file bufferManipulation.hpp.

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

Definition at line 315 of file bufferManipulation.hpp.

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

Definition at line 297 of file bufferManipulation.hpp.

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

Definition at line 373 of file bufferManipulation.hpp.

◆ free()

template<typename BUFFER >
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.

Definition at line 188 of file bufferManipulation.hpp.

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

Definition at line 338 of file bufferManipulation.hpp.

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

Definition at line 359 of file bufferManipulation.hpp.

◆ reserve()

template<typename BUFFER >
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.

Definition at line 230 of file bufferManipulation.hpp.

◆ resize()

template<typename BUFFER , typename ... ARGS>
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.

Definition at line 272 of file bufferManipulation.hpp.

◆ setCapacity()

template<typename BUFFER >
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.

Definition at line 214 of file bufferManipulation.hpp.