21 template<
typename T,
typename INDEX_TYPE,
template<
typename >
class BUFFER_TYPE >
33 template<
typename >
class BUFFER_TYPE >
38 using ParentClass = ArrayOfSetsView< T, INDEX_TYPE, BUFFER_TYPE >;
57 ArrayOfSets( INDEX_TYPE
const nsets=0, INDEX_TYPE defaultSetCapacity=0 ):
60 resize( nsets, defaultSetCapacity );
102 src.m_offsets[ src.m_numArrays ],
135 INDEX_TYPE
const numSets =
size();
136 if( desc == sortedArrayManipulation::UNSORTED_NO_DUPLICATES )
138 for( INDEX_TYPE i = 0; i < numSets; ++i )
141 INDEX_TYPE
const numValues =
sizeOfSet( i );
142 std::sort( setValues, setValues + numValues );
145 if( desc == sortedArrayManipulation::SORTED_WITH_DUPLICATES )
147 for( INDEX_TYPE i = 0; i < numSets; ++i )
150 INDEX_TYPE
const numValues =
sizeOfSet( i );
154 this->
m_sizes[ i ] = numUniqueValues;
157 if( desc == sortedArrayManipulation::UNSORTED_WITH_DUPLICATES )
159 for( INDEX_TYPE i = 0; i < numSets; ++i )
162 INDEX_TYPE
const numValues =
sizeOfSet( i );
166 this->
m_sizes[ i ] = numUniqueValues;
170 #ifdef ARRAY_BOUNDS_CHECK 204 toView()
const && =
delete;
282 using ParentClass::operator[];
283 using ParentClass::operator();
301 void resize( INDEX_TYPE
const newSize, INDEX_TYPE
const defaultArrayCapacity=0 )
340 INDEX_TYPE
const offset = this->
m_offsets[i];
390 template<
typename ITER >
392 INDEX_TYPE
insertIntoSet( INDEX_TYPE
const i, ITER
const first, ITER
const last )
414 template<
typename ITER >
416 INDEX_TYPE
removeFromSet( INDEX_TYPE
const i, ITER
const first, ITER
const last )
const 427 INDEX_TYPE
const prevSize =
sizeOfSet( i );
477 { ParentClass::template setName< decltype( *this ) >( name ); }
497 CallBacks(
ArrayOfSets & aos, INDEX_TYPE
const i ):
511 T * incrementSize( T *
const curPtr, INDEX_TYPE
const nToAdd )
const 514 INDEX_TYPE
const newNNZ = m_aos.sizeOfSet( m_i ) + nToAdd;
515 if( newNNZ > m_aos.capacityOfSet( m_i ) )
517 m_aos.setCapacityOfSet( m_i, 2 * newNNZ );
520 return m_aos.getSetValues( m_i );
528 INDEX_TYPE
const m_i;
constexpr ArrayOfSetsView< T const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const &
#define LVARRAY_UNUSED_VARIABLE(X)
Mark X as an unused variable, used to silence compiler warnings.
void emplace(BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos, ARGS &&... args)
Construct a new value at position pos.
ArrayOfSets & operator=(ArrayOfSets const &src)
Copy assignment operator, performs a deep copy.
#define LVARRAY_ASSERT(EXP)
Assert EXP is true with no message.
constexpr ArrayOfArraysView< T const, INDEX_TYPE const, true, BUFFER_TYPE > toArrayOfArraysView() const &
bool insertIntoSet(INDEX_TYPE const i, T const &val)
Insert a value into the given set.
void setCapacityOfSet(INDEX_TYPE const i, INDEX_TYPE newCapacity)
Set the capacity of a set.
void emplaceBack(BUFFER &buf, std::ptrdiff_t const size, ARGS &&... args)
Construct a new value at the end of the buffer.
#define ARRAYOFARRAYS_CHECK_BOUNDS(i)
Check that i is a valid array index.
LvArray::ArrayOfSets< T, localIndex, LvArray::ChaiBuffer > ArrayOfSets
Array of variable-sized sets. See LvArray::ArrayOfSets for details.
void eraseSet(INDEX_TYPE const i)
Erase a set.
bool removeFromSet(INDEX_TYPE const i, T const &value) const
Remove a value from the given set.
INDEX_TYPE size_type
The integer type used for indexing, here for stl compatability.
bool insertIntoSetImpl(INDEX_TYPE const i, T const &value, CALLBACKS &&cbacks) const
Helper function to insert a value into the given set.
void reserve(INDEX_TYPE const newCapacity)
Reserve space for the given number of arrays.
INDEX_TYPE IndexType
The integer type used for indexing.
BUFFER_TYPE< INDEX_TYPE > m_offsets
constexpr INDEX_TYPE_NC sizeOfSet(INDEX_TYPE const i) const
constexpr ArrayOfSetsView< T, INDEX_TYPE const, BUFFER_TYPE > toView() const
constexpr INDEX_TYPE_NC size() const
ArrayOfSets(ArrayOfSets const &src)
Copy constructor, performs a deep copy.
BUFFER_TYPE< SIZE_TYPE > m_sizes
Holds the size of each array.
void setName(std::string const &name)
Set the name to be displayed whenever the underlying Buffer's user call back is called.
T value_type
An alias for the type contained in the inner arrays, here for stl compatability.
void compress(BUFFERS &... buffers)
Compress the arrays so that the values of each array are contiguous with no extra capacity in between...
void move(MemorySpace const space, bool const touch=true) const
Move this ArrayOfSets to the given memory space.
This class implements an array of arrays like object with contiguous storage.
constexpr std::enable_if< std::is_signed< INDEX_TYPE >::value, bool >::type isPositive(INDEX_TYPE const i)
void resize(INDEX_TYPE const newSize, INDEX_TYPE const defaultArrayCapacity=0)
Set the number of arrays.
void reserveCapacityOfSet(INDEX_TYPE const i, INDEX_TYPE newCapacity)
Reserve space in a set.
constexpr ArraySlice< T, 1, 0, INDEX_TYPE_NC > getSetValues(INDEX_TYPE const i) const
constexpr ArrayOfSetsView< T const, INDEX_TYPE const, BUFFER_TYPE > toViewConst() const
This class provides a no-op callbacks interface for the ArrayManipulation sorted routines.
This class provides a view into an array of sets like object.
This class provides a view into an array of arrays like object.
INDEX_TYPE insertIntoSet(INDEX_TYPE const i, ITER const first, ITER const last)
Inserts multiple values into the given set.
bool contains(INDEX_TYPE const i, T const &value) const
void assimilate(ArrayOfArrays< T, INDEX_TYPE, BUFFER_TYPE > &&src, sortedArrayManipulation::Description const desc)
Steal the resources from an ArrayOfArrays and convert it to an ArrayOfSets.
void clearSet(INDEX_TYPE const i)
Clear a set.
constexpr INDEX_TYPE_NC capacityOfSet(INDEX_TYPE const i) const
LvArray::ArrayOfArrays< T, localIndex, LvArray::ChaiBuffer > ArrayOfArrays
Array of variable-sized arrays. See LvArray::ArrayOfArrays for details.
void insertSet(INDEX_TYPE const i, INDEX_TYPE const setCapacity=0)
Insert a set at position i with capacity setCapacity.
void move(MemorySpace const space, bool const touch=true) const
Move this ArrayOfSets to the given memory space.
std::ptrdiff_t makeSortedUnique(ITER const first, ITER const last, Compare &&comp=Compare())
Sort and remove duplicates from the array, duplicates aren't destroyed but they're moved out of...
#define ARRAYOFARRAYS_CHECK_INSERT_BOUNDS(i)
Check that i is a valid index to insert an array at.
CONSTEXPR_WITH_NDEBUG INDEX_TYPE_NC capacity() const
MemorySpace
An enum containing the available memory spaces.
void setCapacity(BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const newCapacity)
Set the capacity of the buffer.
constexpr ArrayOfSetsView< T, INDEX_TYPE const, BUFFER_TYPE > toView() const &
This class implements an array of sets like object with contiguous storage.
void resizeFromCapacities(INDEX_TYPE const numSubArrays, INDEX_TYPE const *const capacities, BUFFERS &... buffers)
Clears the array and creates a new array with the given number of sub-arrays.
ArrayOfSets(INDEX_TYPE const nsets=0, INDEX_TYPE defaultSetCapacity=0)
Constructor.
void consistencyCheck() const
Verify that the capacity of each set is greater than or equal to the size and that each set is sorted...
void setEqualTo(INDEX_TYPE const srcNumArrays, INDEX_TYPE const srcMaxOffset, BUFFER_TYPE< INDEX_TYPE > const &srcOffsets, BUFFER_TYPE< INDEX_TYPE > const &srcSizes, BUFFER_TYPE< T > const &srcValues, PAIRS_OF_BUFFERS &&... pairs)
Set this ArrayOfArraysView equal to the provided arrays.
void appendSet(INDEX_TYPE const setCapacity=0)
Append a set with capacity setCapacity.
void resize(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size, std::ptrdiff_t const newSize, ARGS &&... args)
Resize the give array.
INDEX_TYPE_NC m_numArrays
The number of arrays contained.
void free(BUFFERS &... buffers)
Destroy all the objects held by this array and free all associated memory.
~ArrayOfSets()
Destructor, frees the values, sizes and offsets Buffers.
ArrayOfSetsView & operator=(ArrayOfSetsView const &)=default
Default copy assignment operator, this does a shallow copy.
void setCapacityOfArray(INDEX_TYPE const i, INDEX_TYPE const newCapacity, BUFFERS &... buffers)
Set the capacity of the given array.
void assimilate(ArrayOfArraysView< T, INDEX_TYPE, CONST_SIZES, BUFFER_TYPE > &&src)
Steal the resources of src, clearing it in the process.
Contains the implementation of LvArray::ArrayOfSetsView.
bool removeFromSet(INDEX_TYPE const i, T const &value) const
Remove a value from the given set.
INDEX_TYPE removeFromSet(INDEX_TYPE const i, ITER const first, ITER const last) const
Removes multiple values from the given set.
LvArray::ArrayOfSetsView< T, localIndex const, LvArray::ChaiBuffer > ArrayOfSetsView
View of array of variable-sized sets. See LvArray::ArrayOfSetsView for details.
std::string string
String type.
void resize(INDEX_TYPE const newSize, INDEX_TYPE const defaultArrayCapacity=0)
Set the number of arrays.
constexpr ArrayOfArraysView< T const, INDEX_TYPE const, true, BUFFER_TYPE > toArrayOfArraysView() const
ArrayOfSets & operator=(ArrayOfSets &&src)
Default move assignment operator, performs a shallow copy.
void reserveValues(INDEX_TYPE const newValueCapacity, BUFFERS &... buffers)
Reserve space for the given number of values.
std::ptrdiff_t removeDuplicates(ITER first, ITER const last, Compare &&comp=Compare())
Remove duplicates from the array, duplicates aren't destroyed but they're moved out of...
constexpr INDEX_TYPE_NC valueCapacity() const
void erase(BUFFER &buf, std::ptrdiff_t const size, std::ptrdiff_t const pos)
Erase a value from the buffer.
Description
Describes an as some combination of sorted/unsorted and unique/with duplicates.
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
T ValueType
An alias for the type contained in the inner arrays.