User Manual, Developers Guide and API Documentation

wns::container::RangeMap< RangeType, ValueType, CleanupStrategy > Class Template Reference

Maps with intervals. More...

#include <container/RangeMap.hpp>

Inheritance diagram for wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >:

Inheritance graph
[legend]
Collaboration diagram for wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef RangeType Index
 Type of the index used by get().
typedef Interval< IndexIntervalType
 Type of the interval used by insert().
typedef ValueType Value
 Type of the values stored.

Public Member Functions

const Valueget (const Index &index) const
 Get the value for an index.
bool has (const Index &index) const
 Check if an interval for index has been defined.
RangeMapinsert (const IntervalType &interval, const ValueType &value)
 Insert a value for a given interval.
 RangeMap ()
 Default constructor.
virtual ~RangeMap ()
 Destructor.

Private Types

typedef std::pair
< IntervalType, Value
IntervalValuePair
typedef BinaryTree
< IntervalValuePair,
CleanupStrategy > 
RangeTree

Private Member Functions

void insert (const IntervalValuePair &intervalValue, RangeTree *node)

Private Attributes

RangeTreeroot

Classes

class  Exception
 This exception is thrown by RangeMap members. More...


Detailed Description

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
class wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >

RangeMap lets you define intervals, for which you want to return certain values. Say you want to get a 42 for indices between 0.0 and 23.0 and a 5 for indices between 23.8 and 151.6, you can use a RangeMap<float, int> for this. Intervals must not overlap.

You can create RangeMaps of abstract classes (e.g. RangeMap<float, ArgumentFunctor<float> >), you just need to insert objects of derived classes.

RangeMap uses a tree internally, but currently does not concern about its balance. Thus if you insert n intervals in order, get() will need O(n) comparisons, as the tree will be a list effectively.

Definition at line 54 of file RangeMap.hpp.


Member Typedef Documentation

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
typedef RangeType wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::Index

Definition at line 72 of file RangeMap.hpp.

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
typedef Interval<Index> wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::IntervalType

Definition at line 76 of file RangeMap.hpp.

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
typedef std::pair<IntervalType, Value> wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::IntervalValuePair [private]

Definition at line 158 of file RangeMap.hpp.

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
typedef BinaryTree<IntervalValuePair, CleanupStrategy > wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::RangeTree [private]

Todo:
(swen) balanced tree

Definition at line 160 of file RangeMap.hpp.

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
typedef ValueType wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::Value

Definition at line 80 of file RangeMap.hpp.


Constructor & Destructor Documentation

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::RangeMap (  )  [inline]

Definition at line 84 of file RangeMap.hpp.

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
virtual wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::~RangeMap (  )  [inline, virtual]

Definition at line 90 of file RangeMap.hpp.


Member Function Documentation

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
const Value& wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::get ( const Index index  )  const [inline]

get() throws Exception, when an interval has not been defined for index.

Parameters:
index The index.
Returns:
Value for index.

Definition at line 125 of file RangeMap.hpp.

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
bool wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::has ( const Index index  )  const [inline]

Parameters:
index The index.
Returns:
True, if a range containing index was found, false otherwise.

Definition at line 145 of file RangeMap.hpp.

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
void wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::insert ( const IntervalValuePair intervalValue,
RangeTree node 
) [inline, private]

Definition at line 162 of file RangeMap.hpp.

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
RangeMap& wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::insert ( const IntervalType interval,
const ValueType &  value 
) [inline]

insert() assures, that interval does not overlap with an existing interval, and that interval is not empty.

Parameters:
interval Define value for this interval.
value Define this valus.
Returns:
Reference to *this.

Definition at line 106 of file RangeMap.hpp.


Member Data Documentation

template<typename RangeType, typename ValueType, typename CleanupStrategy = tree::NoneOnErase>
RangeTree* wns::container::RangeMap< RangeType, ValueType, CleanupStrategy >::root [private]

Definition at line 173 of file RangeMap.hpp.


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

Generated on Sat May 26 03:32:52 2012 for openWNS by  doxygen 1.5.5