AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::sidre::IndexedCollection< T > Class Template Referenceabstract

IndexedCollection is a container for a collection of pointers to items of template parameter type T, each with a corresponding index. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/sidre/core/IndexedCollection.hpp>

Inheritance diagram for axom::sidre::IndexedCollection< T >:

Public Types

using value_type = T
 
using iterator = typename ItemCollection< T >::iterator
 
using const_iterator = typename ItemCollection< T >::const_iterator
 

Public Member Functions

size_t getNumItems () const
 Gets the number of items stored in the collection. More...
 
IndexType getFirstValidIndex () const
 Returns the index of the first valid item or InvalidIndex if there are none. More...
 
IndexType getNextValidIndex (IndexType idx) const
 Returns the next valid index after \idx or InvalidIndex if there are none. More...
 
bool hasItem (IndexType idx) const
 Return true if there is an item at index idx. More...
 
T * getItem (IndexType idx)
 Return the item at index \idx or nullptr if that index is empty. More...
 
T const * getItem (IndexType idx) const
 Return the item at index \idx or nullptr if that index is empty. More...
 
IndexType insertItem (T *item)
 Insert item into the next available free index. More...
 
IndexType insertItem (T *item, const std::string &AXOM_UNUSED_PARAM(name))
 Insert item into the next available free index. More...
 
IndexType insertItem (T *item, IndexType idx)
 Insert item at index idx if that index is not already occupied. More...
 
T * removeItem (IndexType idx)
 Removes the item from index idx but does not destroy it. More...
 
void removeAllItems ()
 Removes all items from the collection, but does not destroy them. More...
 
IndexType getValidEmptyIndex ()
 Return the index of a valid empty slot in the collection. More...
 
IndexType getLastAvailableEmptyIndex () const
 Gets the empty index at the end of the range of available indices. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_iterator begin () const
 
const_iterator end () const
 
virtual IndexType insertItem (T *item, const std::string &name="")=0
 
iterator_adaptor getIteratorAdaptor ()
 Returns an adaptor wrapping this collection in support of iteration. More...
 
const_iterator_adaptor getIteratorAdaptor () const
 Returns a const adaptor wrapping this collection in support of iteration. More...
 

Detailed Description

template<typename T>
class axom::sidre::IndexedCollection< T >

IndexedCollection is a container for a collection of pointers to items of template parameter type T, each with a corresponding index.

Each item has an associated index which will always be in the range between 0 and getLastAvailableEmptyIndex()

Member Typedef Documentation

◆ value_type

template<typename T >
using axom::sidre::IndexedCollection< T >::value_type = T

◆ iterator

template<typename T >
using axom::sidre::IndexedCollection< T >::iterator = typename ItemCollection<T>::iterator

◆ const_iterator

template<typename T >
using axom::sidre::IndexedCollection< T >::const_iterator = typename ItemCollection<T>::const_iterator

Member Function Documentation

◆ getNumItems()

template<typename T >
size_t axom::sidre::IndexedCollection< T >::getNumItems ( ) const
inlinevirtual

Gets the number of items stored in the collection.

Implements axom::sidre::ItemCollection< T >.

◆ getFirstValidIndex()

template<typename T >
IndexType axom::sidre::IndexedCollection< T >::getFirstValidIndex
virtual

Returns the index of the first valid item or InvalidIndex if there are none.

Implements axom::sidre::ItemCollection< T >.

References axom::sidre::InvalidIndex.

◆ getNextValidIndex()

template<typename T >
IndexType axom::sidre::IndexedCollection< T >::getNextValidIndex ( IndexType  idx) const
virtual

Returns the next valid index after \idx or InvalidIndex if there are none.

Implements axom::sidre::ItemCollection< T >.

References axom::sidre::InvalidIndex.

◆ hasItem()

template<typename T >
bool axom::sidre::IndexedCollection< T >::hasItem ( IndexType  idx) const
inlinevirtual

Return true if there is an item at index idx.

Implements axom::sidre::ItemCollection< T >.

◆ getItem() [1/2]

template<typename T >
T* axom::sidre::IndexedCollection< T >::getItem ( IndexType  idx)
inlinevirtual

Return the item at index \idx or nullptr if that index is empty.

Implements axom::sidre::ItemCollection< T >.

References axom::sidre::IndexedCollection< T >::hasItem().

◆ getItem() [2/2]

template<typename T >
T const* axom::sidre::IndexedCollection< T >::getItem ( IndexType  idx) const
inlinevirtual

Return the item at index \idx or nullptr if that index is empty.

Implements axom::sidre::ItemCollection< T >.

References axom::sidre::IndexedCollection< T >::hasItem().

◆ insertItem() [1/4]

template<typename T >
IndexType axom::sidre::IndexedCollection< T >::insertItem ( T *  item)
inline

Insert item into the next available free index.

References axom::sidre::IndexedCollection< T >::getValidEmptyIndex().

◆ insertItem() [2/4]

template<typename T >
IndexType axom::sidre::IndexedCollection< T >::insertItem ( T *  item,
const std::string &  AXOM_UNUSED_PARAMname 
)
inline

Insert item into the next available free index.

Note
The second parameter is unused and only present to conform to the ItemCollection interface

References axom::sidre::IndexedCollection< T >::insertItem().

◆ insertItem() [3/4]

template<typename T >
IndexType axom::sidre::IndexedCollection< T >::insertItem ( T *  item,
IndexType  idx 
)
inline

Insert item at index idx if that index is not already occupied.

Returns
Index at which item was inserted, if successful; sidre::InvalidIndex otherwise

References axom::sidre::IndexedCollection< T >::getLastAvailableEmptyIndex(), axom::sidre::IndexedCollection< T >::hasItem(), and axom::sidre::InvalidIndex.

◆ removeItem()

template<typename T >
T * axom::sidre::IndexedCollection< T >::removeItem ( IndexType  idx)
virtual

Removes the item from index idx but does not destroy it.

Implements axom::sidre::ItemCollection< T >.

◆ removeAllItems()

template<typename T >
void axom::sidre::IndexedCollection< T >::removeAllItems ( )
inlinevirtual

Removes all items from the collection, but does not destroy them.

Warning
This function can leak memory if the collection stores a pointer to the only copy of the items

Implements axom::sidre::ItemCollection< T >.

◆ getValidEmptyIndex()

template<typename T >
IndexType axom::sidre::IndexedCollection< T >::getValidEmptyIndex ( )
inline

Return the index of a valid empty slot in the collection.

Finds an empty (unused) index at which an item can be inserted

References axom::sidre::IndexedCollection< T >::hasItem(), axom::sidre::InvalidIndex, and SLIC_ASSERT_MSG.

◆ getLastAvailableEmptyIndex()

template<typename T >
IndexType axom::sidre::IndexedCollection< T >::getLastAvailableEmptyIndex ( ) const
inline

Gets the empty index at the end of the range of available indices.

Note
This index will always be empty

◆ begin() [1/2]

template<typename T >
iterator axom::sidre::IndexedCollection< T >::begin ( )
inlinevirtual

◆ end() [1/2]

template<typename T >
iterator axom::sidre::IndexedCollection< T >::end ( )
inlinevirtual

◆ cbegin()

template<typename T >
const_iterator axom::sidre::IndexedCollection< T >::cbegin ( ) const
inlinevirtual

◆ cend()

template<typename T >
const_iterator axom::sidre::IndexedCollection< T >::cend ( ) const
inlinevirtual

◆ begin() [2/2]

template<typename T >
const_iterator axom::sidre::IndexedCollection< T >::begin ( ) const
inlinevirtual

◆ end() [2/2]

template<typename T >
const_iterator axom::sidre::IndexedCollection< T >::end ( ) const
inlinevirtual

◆ insertItem() [4/4]

template<typename T >
virtual IndexType axom::sidre::ItemCollection< T >::insertItem ( T *  item,
const std::string &  name = "" 
)
pure virtualinherited

◆ getIteratorAdaptor() [1/2]

template<typename T >
iterator_adaptor axom::sidre::ItemCollection< T >::getIteratorAdaptor ( )
inlineinherited

Returns an adaptor wrapping this collection in support of iteration.

◆ getIteratorAdaptor() [2/2]

template<typename T >
const_iterator_adaptor axom::sidre::ItemCollection< T >::getIteratorAdaptor ( ) const
inlineinherited

Returns a const adaptor wrapping this collection in support of iteration.


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