AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
A Set class that supports dynamically adding and removing set items. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.5.0/src/axom/slam/DynamicSet.hpp>
Classes | |
class | SetBuilder |
Helper class for constructing a DynamicSet. More... | |
Public Types | |
enum | { INVALID_ENTRY = ~0 } |
using | PositionType = PosType |
using | ElementType = PosType |
using | SetVectorType = std::vector< ElementType > |
using | SizePolicyType = SizePolicy |
Public Member Functions | |
DynamicSet (PositionType size=SizePolicyType::DEFAULT_VALUE) | |
Constructor for a DynamicSet. More... | |
DynamicSet (const SetBuilder &builder) | |
Constructor for a DynamicSet from a SetBuilder. More... | |
DynamicSet element access functions | |
ElementType | at (PositionType pos) const |
Access the element at position pos. More... | |
ElementType | operator[] (IndexType pos) const |
Access the element at position pos. More... | |
ElementType & | operator[] (IndexType pos) |
Access the element at position pos. More... | |
SetVectorType & | data () |
Returns a reference to the underlying set data. More... | |
const SetVectorType & | data () const |
Returns a const reference to the underlying set data. More... | |
IndexType | findIndex (ElementType e) |
Given a value, find the index of the first entry containing it. More... | |
Functions that deal with the set cardinality | |
PositionType | size () const |
Returns the number of possible elements in the set. More... | |
bool | empty () const |
Uses SizePolicy::empty() to determine if the set is empty. More... | |
PositionType | numberOfValidEntries () const |
Return the number of valid entries in the set. More... | |
bool | isSubset () const |
Returns true if this set is a subset of another set. More... | |
Functions that deal with validity checks | |
bool | isValidEntry (IndexType i) const |
Predicate to check if the entry at index i is valid. More... | |
bool | isValid (bool verboseOutput=false) const |
Returns true if the DynamicSet instance is valid. More... | |
Functions that modify the set cardinality | |
IndexType | insert () |
Insert an entry at the end of the set with value = ( size()-1 ) More... | |
IndexType | insert (ElementType val) |
Insert an entry at the end of the set with the given value. More... | |
void | remove (IndexType idx) |
Mark the corresponding entry as invalid. More... | |
A Set class that supports dynamically adding and removing set items.
An entry in the set is valid if it is not equal to INVALID_ENTRY.
An example to traverse the elements
using axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::PositionType = PosType |
using axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::ElementType = PosType |
using axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::SetVectorType = std::vector<ElementType> |
using axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::SizePolicyType = SizePolicy |
anonymous enum |
|
inline |
Constructor for a DynamicSet.
size | The initial size of the set |
References axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::size().
|
inline |
Constructor for a DynamicSet from a SetBuilder.
|
inlinevirtual |
Access the element at position pos.
Implements axom::slam::Set< PosType, ElemType >.
References axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::operator[]().
Referenced by axom::slam::DynamicConstantRelation< PosType, ElemType, CardinalityPolicy >::isValid().
|
inline |
Access the element at position pos.
Referenced by axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::at().
|
inline |
Access the element at position pos.
|
inline |
Returns a reference to the underlying set data.
|
inline |
Returns a const reference to the underlying set data.
|
inline |
Given a value, find the index of the first entry containing it.
References axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::INVALID_ENTRY.
|
inlinevirtual |
Returns the number of possible elements in the set.
Implements axom::slam::Set< PosType, ElemType >.
Referenced by axom::slam::DynamicConstantRelation< PosType, ElemType, CardinalityPolicy >::data(), axom::slam::DynamicConstantRelation< PosType, ElemType, CardinalityPolicy >::DynamicConstantRelation(), axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::DynamicSet(), and axom::slam::DynamicConstantRelation< PosType, ElemType, CardinalityPolicy >::isValid().
|
inlinevirtual |
Uses SizePolicy::empty() to determine if the set is empty.
Implements axom::slam::Set< PosType, ElemType >.
|
inline |
Return the number of valid entries in the set.
This is an O(n) operation, because the class makes no assumption that data was not changed by the user
References axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::INVALID_ENTRY.
|
inlinevirtual |
Returns true if this set is a subset of another set.
Implements axom::slam::Set< PosType, ElemType >.
|
inline |
Predicate to check if the entry at index i is valid.
The entry is valid when 0 <= i < size() and the value at index i is not marked as INVALID_ENTRY
References axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::INVALID_ENTRY.
Referenced by axom::slam::DynamicConstantRelation< PosType, ElemType, CardinalityPolicy >::isValid().
|
inlinevirtual |
Returns true if the DynamicSet instance is valid.
A DynamicSet is valid if each of its policies claim it to be valid. This includes its SizePolicy, OffsetPolicy and StridePolicy
Implements axom::slam::Set< PosType, ElemType >.
|
inline |
Insert an entry at the end of the set with value = ( size()-1 )
References axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::insert().
Referenced by axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::insert().
|
inline |
Insert an entry at the end of the set with the given value.
val | the value of the inserted entry |
|
inline |
Mark the corresponding entry as invalid.
References AXOM_DEBUG_PARAM, axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::INVALID_ENTRY, axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::SetBuilder::size(), and SLIC_ASSERT_MSG.