SG++-Doxygen-Documentation
sgpp::combigrid::TreeStorage< T > Class Template Reference

The TreeStorage class is an optimized implementation of a storage that stores values addressed by MultiIndex-objects. More...

#include <TreeStorage.hpp>

Inheritance diagram for sgpp::combigrid::TreeStorage< T >:
sgpp::combigrid::AbstractMultiStorage< T >

Public Types

typedef std::function< T(MultiIndex const &)> function_type
 

Public Member Functions

virtual bool containsIndex (MultiIndex const &index) const
 
virtual T & get (MultiIndex const &index)
 Returns the value for the given MultiIndex. More...
 
virtual std::shared_ptr< AbstractMultiStorageIterator< T > > getGuidedIterator (MultiIndexIterator &indexIter, IterationPolicy const &policy=IterationPolicy::Default)
 
virtual size_t getNumDimensions () const
 
virtual std::shared_ptr< AbstractMultiStorageIterator< T > > getStoredDataIterator ()
 
virtual void set (MultiIndex const &index, T const &value)
 Unlike get(), this function does not activate a computation if there is no entry for the given multi-index in the storage. More...
 
virtual void setFunc (function_type func)
 Changes the function that generates the entries. More...
 
 TreeStorage (size_t numDimensions, function_type func=multiIndexToDefaultValue< T >())
 Constructor. More...
 
virtual ~TreeStorage ()
 
- Public Member Functions inherited from sgpp::combigrid::AbstractMultiStorage< T >
virtual ~AbstractMultiStorage ()
 

Detailed Description

template<typename T>
class sgpp::combigrid::TreeStorage< T >

The TreeStorage class is an optimized implementation of a storage that stores values addressed by MultiIndex-objects.

It uses a tree with as many levels as dimensions in the multi-indices. TreeStorage can be configured with a function that computes a value for a multi-index such that TreeStorage caches its values. Multi-Indices start from 0 in each dimension. The class T has to have a default constructor. For more information see AbstractMultiStorage.

Member Typedef Documentation

◆ function_type

template<typename T >
typedef std::function<T(MultiIndex const &)> sgpp::combigrid::TreeStorage< T >::function_type

Constructor & Destructor Documentation

◆ TreeStorage()

template<typename T >
sgpp::combigrid::TreeStorage< T >::TreeStorage ( size_t  numDimensions,
function_type  func = multiIndexToDefaultValue<T>() 
)
inlineexplicit

Constructor.

Parameters
numDimensionsnumber of dimensions of the multi-indices that the storage is addressed with
func"Default-value-function" that is called to compute entries that are not already stored. If this parameter is not specified, func will be set to a function returning T(). The storage might serve as a function value cache such that these values only have to be computed once. If no function is specified, the default constructor of the stored type is used.

◆ ~TreeStorage()

template<typename T >
virtual sgpp::combigrid::TreeStorage< T >::~TreeStorage ( )
inlinevirtual

Member Function Documentation

◆ containsIndex()

template<typename T >
virtual bool sgpp::combigrid::TreeStorage< T >::containsIndex ( MultiIndex const &  index) const
inlinevirtual
Returns
Returns true iff the storage contains a value for the given MultiIndex.

Implements sgpp::combigrid::AbstractMultiStorage< T >.

◆ get()

template<typename T >
virtual T& sgpp::combigrid::TreeStorage< T >::get ( MultiIndex const &  index)
inlinevirtual

Returns the value for the given MultiIndex.

If the value is not stored, it is computed using the function and then stored and returned.

Implements sgpp::combigrid::AbstractMultiStorage< T >.

References sgpp::combigrid::TreeStorageContext< T >::numDimensions.

◆ getGuidedIterator()

template<typename T >
virtual std::shared_ptr<AbstractMultiStorageIterator<T> > sgpp::combigrid::TreeStorage< T >::getGuidedIterator ( MultiIndexIterator indexIter,
IterationPolicy const &  policy = IterationPolicy::Default 
)
inlinevirtual
Parameters
indexIterIterator that defines which values should be iterated over.
policyDefines for each dimension the order that the values should be traversed in.
Returns
Returns an iterator that iterates over all values that indexIter iterates over, possibly creating them on-the-fly. Depending on the given policy, the values are not traversed in their natural order but in an order given by the iterators in the policy.

Implements sgpp::combigrid::AbstractMultiStorage< T >.

References sgpp::combigrid::TreeStorageContext< T >::numDimensions.

◆ getNumDimensions()

template<typename T >
virtual size_t sgpp::combigrid::TreeStorage< T >::getNumDimensions ( ) const
inlinevirtual

◆ getStoredDataIterator()

template<typename T >
virtual std::shared_ptr<AbstractMultiStorageIterator<T> > sgpp::combigrid::TreeStorage< T >::getStoredDataIterator ( )
inlinevirtual
Returns
Returns an iterator that iterates over all values that are already stored in the storage.

Implements sgpp::combigrid::AbstractMultiStorage< T >.

References sgpp::combigrid::TreeStorageContext< T >::numDimensions.

◆ set()

template<typename T >
virtual void sgpp::combigrid::TreeStorage< T >::set ( MultiIndex const &  index,
T const &  value 
)
inlinevirtual

Unlike get(), this function does not activate a computation if there is no entry for the given multi-index in the storage.

Instead, it directly sets the given value.

Implements sgpp::combigrid::AbstractMultiStorage< T >.

◆ setFunc()

template<typename T >
virtual void sgpp::combigrid::TreeStorage< T >::setFunc ( function_type  func)
inlinevirtual

Changes the function that generates the entries.

References sgpp::combigrid::TreeStorageContext< T >::func.


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