AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy > Class Template Reference

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>

Inheritance diagram for axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >:

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...
 
ElementTypeoperator[] (IndexType pos)
 Access the element at position pos. More...
 
SetVectorTypedata ()
 Returns a reference to the underlying set data. More...
 
const SetVectorTypedata () 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...
 

Detailed Description

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
class axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >

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

DynamicSet<> some_set;
... // initialize some_set
const IndexType N = some_set.size()
for(IndexType i=0; i< N; ++i)
{
if( some_set.isValidEntry(i) )
{
ElementType el = some_set[i];
... // do something with el
} // END if the entry is valid
} //END for all set entries

Member Typedef Documentation

◆ PositionType

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
using axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::PositionType = PosType

◆ ElementType

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
using axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::ElementType = PosType

◆ SetVectorType

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
using axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::SetVectorType = std::vector<ElementType>

◆ SizePolicyType

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
using axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::SizePolicyType = SizePolicy

Member Enumeration Documentation

◆ anonymous enum

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
anonymous enum
Enumerator
INVALID_ENTRY 

value to mark indices of deleted elements

Constructor & Destructor Documentation

◆ DynamicSet() [1/2]

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::DynamicSet ( PositionType  size = SizePolicyType::DEFAULT_VALUE)
inline

Constructor for a DynamicSet.

Parameters
sizeThe initial size of the set
Note
The set entries will be initialized such that set[i] = i

References axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::size().

◆ DynamicSet() [2/2]

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::DynamicSet ( const SetBuilder builder)
inline

Constructor for a DynamicSet from a SetBuilder.

Note
The set entries will be initialized such that set[i] = i

Member Function Documentation

◆ at()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
ElementType axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::at ( PositionType  pos) const
inlinevirtual

◆ operator[]() [1/2]

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
ElementType axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::operator[] ( IndexType  pos) const
inline

Access the element at position pos.

Precondition
pos must be between 0 and size()

Referenced by axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::at().

◆ operator[]() [2/2]

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
ElementType& axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::operator[] ( IndexType  pos)
inline

Access the element at position pos.

Precondition
pos must be between 0 and size()

◆ data() [1/2]

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
SetVectorType& axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::data ( )
inline

Returns a reference to the underlying set data.

◆ data() [2/2]

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
const SetVectorType& axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::data ( ) const
inline

Returns a const reference to the underlying set data.

◆ findIndex()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
IndexType axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::findIndex ( ElementType  e)
inline

Given a value, find the index of the first entry containing it.

Returns
The index of the first element with value e, or INVALID_ENTRY if none can be found.
Note
This is an O(n) operation

References axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::INVALID_ENTRY.

◆ size()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
PositionType axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::size ( ) const
inlinevirtual

◆ empty()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
bool axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::empty ( ) const
inlinevirtual

Uses SizePolicy::empty() to determine if the set is empty.

Implements axom::slam::Set< PosType, ElemType >.

◆ numberOfValidEntries()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
PositionType axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::numberOfValidEntries ( ) const
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.

◆ isSubset()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
bool axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::isSubset ( ) const
inlinevirtual

Returns true if this set is a subset of another set.

Implements axom::slam::Set< PosType, ElemType >.

◆ isValidEntry()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
bool axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::isValidEntry ( IndexType  i) const
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().

◆ isValid()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
bool axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::isValid ( bool  verboseOutput = false) const
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 >.

◆ insert() [1/2]

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
IndexType axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::insert ( )
inline

◆ insert() [2/2]

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
IndexType axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::insert ( ElementType  val)
inline

Insert an entry at the end of the set with the given value.

Parameters
valthe value of the inserted entry

◆ remove()

template<typename PosType = slam::DefaultPositionType, typename ElemType = slam::DefaultElementType, typename SizePolicy = policies::DynamicRuntimeSize<PosType>, typename OffsetPolicy = policies::ZeroOffset<PosType>, typename StridePolicy = policies::StrideOne<PosType>>
void axom::slam::DynamicSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy >::remove ( IndexType  idx)
inline

The documentation for this class was generated from the following file: