Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos::StringIndexedOrderedValueObjectContainer< ObjType > Class Template Reference

String indexed ordered value-type object container class. More...

#include <Teuchos_StringIndexedOrderedValueObjectContainer.hpp>

Inheritance diagram for Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >:
Teuchos::StringIndexedOrderedValueObjectContainerBase

Public Types

Public types.
typedef StringIndexedOrderedValueObjectContainerBase::Ordinal Ordinal
 Ordinal used for the index.
typedef FilteredIterator< typename key_and_obj_array_t::iterator, SelectActive< ObjType > > Iterator
 The non-const iterator type.
typedef FilteredIterator< typename key_and_obj_array_t::const_iterator, SelectActive< ObjType > > ConstIterator
 The const iterator type.

Public Member Functions

Constructors/Destructors/Info
 StringIndexedOrderedValueObjectContainer ()
Ordinal numObjects () const
Ordinal numStorage () const
Set, get, and remove functions
template<typename U, typename = std::enable_if_t<std::is_convertible_v<U, ObjType>>>
Ordinal setObj (const std::string &key, U &&obj)
 Set (or reset) object by value and return its ordinal index.
Ordinal getObjOrdinalIndex (const std::string &key) const
 Get the ordinal index given the string key.
Ptr< ObjType > getNonconstObjPtr (const Ordinal &idx)
 Get a nonconst semi-persisting association with the stored object indexed by ordinal.
Ptr< const ObjType > getObjPtr (const Ordinal &idx) const
 Get a const semi-persisting association with the stored object indexed by ordinal.
Ptr< ObjType > getNonconstObjPtr (const std::string &key)
 Get a nonconst semi-persisting association with the stored object indexed by string key.
Ptr< const ObjType > getObjPtr (const std::string &key) const
 Get a const semi-persisting association with the stored object indexed by string key.
void removeObj (const Ordinal &idx)
 Remove an object given its ordinal index.
void removeObj (const std::string &key)
 Remove an object given its string key.

Iterator access

Iterator nonconstBegin ()
Iterator nonconstEnd ()
ConstIterator begin () const
ConstIterator end () const

Detailed Description

template<class ObjType>
class Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >

String indexed ordered value-type object container class.

This class is a simple utility class for managing the storage and retrievel of value-type objects which the following features/properties:

  • Objects are held by-value (i.e., like std::vector, std::map, etc.)
  • Objects are indexed by a unique string key value.
  • Objects can also be indexed by a unique ordering ordinal.
  • Iterators are orderded according to insertion order.

The design of this class comes with a few important limitations:

  • Storage grows accoding to the number of insertions and removing objects does not decrease it. This is a result of the simple implementation needed to preserve ordering
Todo
Implement compression of unused entries. This will invalidate the indexes but will allow handling of lots of inserts and deletes of elements.

Definition at line 151 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

Member Typedef Documentation

◆ Ordinal

◆ Iterator

template<class ObjType>
typedef FilteredIterator<typename key_and_obj_array_t::iterator, SelectActive<ObjType> > Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::Iterator

The non-const iterator type.

Definition at line 173 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ ConstIterator

template<class ObjType>
typedef FilteredIterator<typename key_and_obj_array_t::const_iterator, SelectActive<ObjType> > Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::ConstIterator

The const iterator type.

Definition at line 177 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

Constructor & Destructor Documentation

◆ StringIndexedOrderedValueObjectContainer()

template<class ObjType>
Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::StringIndexedOrderedValueObjectContainer ( )

Member Function Documentation

◆ numObjects()

◆ numStorage()

◆ setObj()

template<typename ObjType>
template<typename U, typename>
StringIndexedOrderedValueObjectContainer< ObjType >::Ordinal Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::setObj ( const std::string & key,
U && obj )

Set (or reset) object by value and return its ordinal index.

If the object with the given key index does not exist, it will be added. If an object with the given key does not exist, it will be created.

Returns
Returns the ordinal index by which the object can be looked up with.

Definition at line 449 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ getObjOrdinalIndex()

template<class ObjType>
StringIndexedOrderedValueObjectContainer< ObjType >::Ordinal Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::getObjOrdinalIndex ( const std::string & key) const
inline

Get the ordinal index given the string key.

If the key does not exist, then getInvalidOrdinal() is returned.

Definition at line 436 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ getNonconstObjPtr() [1/2]

template<class ObjType>
Ptr< ObjType > Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::getNonconstObjPtr ( const Ordinal & idx)
inline

Get a nonconst semi-persisting association with the stored object indexed by ordinal.

Definition at line 325 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ getObjPtr() [1/2]

template<class ObjType>
Ptr< const ObjType > Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::getObjPtr ( const Ordinal & idx) const
inline

Get a const semi-persisting association with the stored object indexed by ordinal.

Definition at line 334 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ getNonconstObjPtr() [2/2]

template<class ObjType>
Ptr< ObjType > Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::getNonconstObjPtr ( const std::string & key)
inline

Get a nonconst semi-persisting association with the stored object indexed by string key.

Definition at line 343 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ getObjPtr() [2/2]

template<class ObjType>
Ptr< const ObjType > Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::getObjPtr ( const std::string & key) const
inline

Get a const semi-persisting association with the stored object indexed by string key.

Definition at line 352 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ removeObj() [1/2]

template<class ObjType>
void Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::removeObj ( const Ordinal & idx)

Remove an object given its ordinal index.

Each object is errased by assigning to a default-constructed ObjType(). This, for example, will wipe out the reference count for a smart pointer class or will unsize an array, etc..

Definition at line 468 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ removeObj() [2/2]

template<class ObjType>
void Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::removeObj ( const std::string & key)

Remove an object given its string key.

Definition at line 477 of file Teuchos_StringIndexedOrderedValueObjectContainer.hpp.

◆ nonconstBegin()

template<class ObjType>
StringIndexedOrderedValueObjectContainer< ObjType >::Iterator Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::nonconstBegin ( )
inline

◆ nonconstEnd()

template<class ObjType>
StringIndexedOrderedValueObjectContainer< ObjType >::Iterator Teuchos::StringIndexedOrderedValueObjectContainer< ObjType >::nonconstEnd ( )
inline

◆ begin()

◆ end()


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