INET Framework for OMNeT++/OMNEST
inet::physicallayer::Nearest< _ContainerType > Class Template Reference

Given two iterators defining a range of key-value-pairs this class provides interpolation of values for an arbitrary key by returning the value of the nearest entry. More...

#include <Interpolation.h>

Inheritance diagram for inet::physicallayer::Nearest< _ContainerType >:
inet::physicallayer::InterpolatorBase< _ContainerType >

Public Types

typedef base_class_type::storage_type storage_type
 
typedef base_class_type::container_type container_type
 
typedef base_class_type::key_type key_type
 
typedef base_class_type::key_cref_type key_cref_type
 
typedef base_class_type::mapped_type mapped_type
 
typedef base_class_type::mapped_cref_type mapped_cref_type
 
typedef base_class_type::pair_type pair_type
 
typedef base_class_type::iterator iterator
 
typedef base_class_type::const_iterator const_iterator
 
typedef base_class_type::comparator_type comparator_type
 
typedef base_class_type::interpolated interpolated
 
- Public Types inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
typedef _ContainerType storage_type
 
typedef storage_type container_type
 
typedef storage_type::key_type key_type
 
typedef const key_typekey_cref_type
 
typedef storage_type::mapped_type mapped_type
 
typedef const mapped_typemapped_cref_type
 
typedef storage_type::value_type pair_type
 
typedef storage_type::iterator iterator
 
typedef storage_type::const_iterator const_iterator
 
typedef PairLess< pair_type, key_typecomparator_type
 
typedef Interpolated< mapped_typeinterpolated
 

Public Member Functions

 Nearest ()
 
 Nearest (mapped_cref_type oorv)
 
virtual ~Nearest ()
 
virtual interpolated operator() (const const_iterator &first, const const_iterator &last, key_cref_type pos, const_iterator upperBound) const
 Functor operator of this class which interpolates the value at the passed position using the values between the passed Iterators. More...
 
- Public Member Functions inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
 InterpolatorBase ()
 
 InterpolatorBase (mapped_cref_type oorv)
 
virtual ~InterpolatorBase ()
 
bool continueAtOutOfRange (void) const
 
interpolated operator() (const const_iterator &first, const const_iterator &last, key_cref_type pos) const
 Functor operator of this class which interpolates the value at the passed position using the values between the passed Iterators. More...
 
virtual bool isStepping () const
 Represents the interpolator a stepping function. More...
 
void setOutOfRangeVal (mapped_cref_type oorv)
 Getter and Setter method for out of range value. More...
 
mapped_cref_type getOutOfRangeVal (void) const
 

Protected Types

typedef InterpolatorBase< _ContainerType > base_class_type
 

Additional Inherited Members

- Public Attributes inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
comparator_type comp
 Comparator for STL functions. More...
 
- Protected Member Functions inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
interpolated asInterpolated (mapped_cref_type rVal, bool bIsOutOfRange, bool bIsInterpolated=true) const
 
- Protected Attributes inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
bool continueOutOfRange
 
interpolated outOfRangeVal
 

Detailed Description

template<class _ContainerType>
class inet::physicallayer::Nearest< _ContainerType >

Given two iterators defining a range of key-value-pairs this class provides interpolation of values for an arbitrary key by returning the value of the nearest entry.

Author
Karl Wessel

Member Typedef Documentation

template<class _ContainerType >
typedef InterpolatorBase<_ContainerType> inet::physicallayer::Nearest< _ContainerType >::base_class_type
protected
template<class _ContainerType >
typedef base_class_type::comparator_type inet::physicallayer::Nearest< _ContainerType >::comparator_type
template<class _ContainerType >
typedef base_class_type::const_iterator inet::physicallayer::Nearest< _ContainerType >::const_iterator
template<class _ContainerType >
typedef base_class_type::container_type inet::physicallayer::Nearest< _ContainerType >::container_type
template<class _ContainerType >
typedef base_class_type::interpolated inet::physicallayer::Nearest< _ContainerType >::interpolated
template<class _ContainerType >
typedef base_class_type::iterator inet::physicallayer::Nearest< _ContainerType >::iterator
template<class _ContainerType >
typedef base_class_type::key_cref_type inet::physicallayer::Nearest< _ContainerType >::key_cref_type
template<class _ContainerType >
typedef base_class_type::key_type inet::physicallayer::Nearest< _ContainerType >::key_type
template<class _ContainerType >
typedef base_class_type::mapped_cref_type inet::physicallayer::Nearest< _ContainerType >::mapped_cref_type
template<class _ContainerType >
typedef base_class_type::mapped_type inet::physicallayer::Nearest< _ContainerType >::mapped_type
template<class _ContainerType >
typedef base_class_type::pair_type inet::physicallayer::Nearest< _ContainerType >::pair_type
template<class _ContainerType >
typedef base_class_type::storage_type inet::physicallayer::Nearest< _ContainerType >::storage_type

Constructor & Destructor Documentation

template<class _ContainerType >
inet::physicallayer::Nearest< _ContainerType >::Nearest ( )
inline
350  :
351  base_class_type() {}
InterpolatorBase< _ContainerType > base_class_type
Definition: Interpolation.h:334
template<class _ContainerType >
inet::physicallayer::Nearest< _ContainerType >::Nearest ( mapped_cref_type  oorv)
inline
353  :
354  base_class_type(oorv) {}
InterpolatorBase< _ContainerType > base_class_type
Definition: Interpolation.h:334
template<class _ContainerType >
virtual inet::physicallayer::Nearest< _ContainerType >::~Nearest ( )
inlinevirtual
356 {}

Member Function Documentation

template<class _ContainerType >
virtual interpolated inet::physicallayer::Nearest< _ContainerType >::operator() ( const const_iterator first,
const const_iterator last,
key_cref_type  pos,
const_iterator  upperBound 
) const
inlinevirtual

Functor operator of this class which interpolates the value at the passed position using the values between the passed Iterators.

The upperBound-iterator has to point two the entry next bigger as the passed position to interpolate.

The returned instance of interpolated represents the result. Which can be either an actual entry of the interpolated map (if the position to interpolate was exactly that. Or it can be an interpolated value, if the passed position was between two entries of the map. This state can be retrieved with the "isInterpolated"-Member of the returned "interpolated".

Returns
The value of a element between first and last which is nearest to pos.

Implements inet::physicallayer::InterpolatorBase< _ContainerType >.

379  {
380  if (first == last) {
382  }
383  if (upperBound == first) {
384  return this->asInterpolated(upperBound->second, true);
385  }
386 
387  const_iterator left = upperBound;
388  --left;
389 
390  if (left->first == pos)
391  return this->asInterpolated(left->second, false, false);
392 
393  const_iterator right = upperBound;
394 
395  if (right == last) {
396  return this->asInterpolated(left->second, true);
397  }
398 
399  return this->asInterpolated(((pos - left->first < right->first - pos) ? left : right)->second, false);
400  }
base_class_type::const_iterator const_iterator
Definition: Interpolation.h:345
interpolated outOfRangeVal
Definition: Interpolation.h:153
interpolated asInterpolated(mapped_cref_type rVal, bool bIsOutOfRange, bool bIsInterpolated=true) const
Definition: Interpolation.h:235

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