INET Framework for OMNeT++/OMNEST
inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType > Class Template Reference

Template for an interpolateable const iterator for any container which maps from a key to a value. More...

#include <Interpolation.h>

Public Types

typedef _Interpolator interpolator_type
 
typedef interpolator_type::container_type container_type
 
typedef interpolator_type::key_type key_type
 
typedef interpolator_type::key_cref_type key_cref_type
 
typedef interpolator_type::mapped_type mapped_type
 
typedef interpolator_type::mapped_cref_type mapped_cref_type
 
typedef interpolator_type::pair_type pair_type
 
typedef interpolator_type::iterator iterator
 
typedef interpolator_type::const_iterator const_iterator
 
typedef interpolator_type::comparator_type comparator_type
 
typedef _IteratorType used_iterator
 
typedef interpolator_type::interpolated interpolated
 typedef for the returned Interpolated value of this class. More...
 

Public Member Functions

 ConstInterpolateableIterator (const used_iterator &first, const used_iterator &last, const interpolator_type &intpl)
 Initializes the iterator with the passed Iterators as boundaries. More...
 
virtual ~ConstInterpolateableIterator ()
 
bool operator== (const ConstInterpolateableIterator &other)
 
void jumpTo (key_cref_type pos)
 Moves the iterator to the passed position. More...
 
void jumpToBegin ()
 Moves the iterator to the first element. More...
 
void iterateTo (key_cref_type pos)
 forward iterates the iterator to the passed position. More...
 
void next ()
 Iterates to the next entry in the underlying data structure. More...
 
key_type getNextPosition ()
 
bool inRange () const
 Returns true if the current position of the iterator is between the position of the first and the last entry of the data structure. More...
 
bool hasNext () const
 Returns true if the a call of "next()" would increase to the position of an a valid entry of the data structure. More...
 
interpolated getValue () const
 Returns the interpolated value at the current position of the Iterator. More...
 
interpolated getNextValue () const
 
key_cref_type getPosition () const
 Returns the current position of the iterator. More...
 
const interpolator_typegetInterpolator () const
 

Protected Attributes

used_iterator first
 
used_iterator last
 
used_iterator right
 
key_type position
 
const interpolator_typeinterpolate
 

Detailed Description

template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
class inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >

Template for an interpolateable const iterator for any container which maps from a key to a value.

This doesn't necessarily has to be a map, but also can be a sorted list of pairs.

The ConstInterpolateableIterator provides an iterator which as able to iterate in arbitrary steps over a iterateable number of pairs of "Key" and "Value". To determine the Value for a Key which does not exist in within the iterateable number of pairs it Interpolates between the nearby existing pairs. The actual Interpolation is determined by the passed Interpolator-template parameter.

An example use would be to be able to iterate over a std::map<double, double> in arbitrary steps (even at positions for which no Key exist inside the map) and be able to return an interpolated Value.

NOTE: The ConstInterpolateableIterator will become invalid if the underlying data structure is changed!

Template parameters: Pair - the type of the pair used as values in the container. Default is std::map<Key, V>::value_type (which is of type std::pair<Key, V>. The Pair type has to provide the two public members "first" and "second". Key - The type of the "first" member of the Pair type V - the type of the "second" member of the Pair type Iterator - the type of the iterator of the container (should be a const iterator). Default is std::map<Key, V>::const_iterator Interpolator - The Interpolation operator to use, this has to be a class which overwrites the ()-operator with the following parameters: Interpolated operator()(const Iterator& first, const Iterator& last, const Key& pos) Interpolated operator()(const Iterator& first, const Iterator& last, const Key& pos, Iterator upperBound) See the NextSmaller template for an example of an Interpolator. Default is NextSmaller<Key, V, Pair, Iterator>.

Author
Karl Wessel

Member Typedef Documentation

template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::comparator_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::comparator_type
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::const_iterator inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::const_iterator
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::container_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::container_type
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::interpolated inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::interpolated

typedef for the returned Interpolated value of this class.

template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef _Interpolator inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::interpolator_type
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::iterator inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::iterator
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::key_cref_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::key_cref_type
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::key_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::key_type
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::mapped_cref_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::mapped_cref_type
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::mapped_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::mapped_type
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef interpolator_type::pair_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::pair_type
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
typedef _IteratorType inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::used_iterator

Constructor & Destructor Documentation

template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::ConstInterpolateableIterator ( const used_iterator first,
const used_iterator last,
const interpolator_type intpl 
)
inline

Initializes the iterator with the passed Iterators as boundaries.

622  :
624  {
625  jumpToBegin();
626  }
void jumpToBegin()
Moves the iterator to the first element.
Definition: Interpolation.h:653
const interpolator_type & interpolate
Definition: Interpolation.h:615
used_iterator first
Definition: Interpolation.h:610
key_type position
Definition: Interpolation.h:614
used_iterator right
Definition: Interpolation.h:612
used_iterator last
Definition: Interpolation.h:611
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
virtual inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::~ConstInterpolateableIterator ( )
inlinevirtual
628 {}

Member Function Documentation

template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
const interpolator_type& inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::getInterpolator ( ) const
inline
764  {
765  return interpolate;
766  }
const interpolator_type & interpolate
Definition: Interpolation.h:615
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
key_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::getNextPosition ( )
inline
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
interpolated inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::getNextValue ( ) const
inline

Referenced by inet::physicallayer::MultiDimMappingIterator< Linear >::updateNextPosition().

745  {
746  if (right == last) {
747  return interpolate(first, last, position + 1, right);
748  }
749  else {
750  const_iterator tmp = right;
751  return interpolate(first, last, right->first, ++tmp);
752  }
753  }
const interpolator_type & interpolate
Definition: Interpolation.h:615
used_iterator first
Definition: Interpolation.h:610
interpolator_type::const_iterator const_iterator
Definition: Interpolation.h:601
key_type position
Definition: Interpolation.h:614
used_iterator right
Definition: Interpolation.h:612
used_iterator last
Definition: Interpolation.h:611
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
interpolated inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::getValue ( ) const
inline

Returns the interpolated value at the current position of the Iterator.

See definition of Interpolated on details on the return type.

Referenced by inet::physicallayer::MappingUtils::findMax(), inet::physicallayer::TimeMappingIterator< Interpolator >::getValue(), inet::physicallayer::FrequencyMappingIterator< Interpolator >::getValue(), inet::physicallayer::MultiDimMappingIterator< Linear >::MultiDimMappingIterator(), and inet::physicallayer::MultiDimMappingIterator< Linear >::updateSubIterator().

740  {
741  return interpolate(first, last, position, right);
742  }
const interpolator_type & interpolate
Definition: Interpolation.h:615
used_iterator first
Definition: Interpolation.h:610
key_type position
Definition: Interpolation.h:614
used_iterator right
Definition: Interpolation.h:612
used_iterator last
Definition: Interpolation.h:611
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
bool inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::hasNext ( ) const
inline

Returns true if the a call of "next()" would increase to the position of an a valid entry of the data structure.

This means if the current position is smaller than position of the last entry.

Referenced by inet::physicallayer::TimeMappingIterator< Interpolator >::hasNext(), inet::physicallayer::FrequencyMappingIterator< Interpolator >::hasNext(), inet::physicallayer::MultiDimMappingIterator< Linear >::hasNext(), and inet::physicallayer::MultiDimMappingIterator< Linear >::updateNextPosition().

729  {
730  return right != last;
731  }
used_iterator right
Definition: Interpolation.h:612
used_iterator last
Definition: Interpolation.h:611
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
bool inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::inRange ( ) const
inline

Returns true if the current position of the iterator is between the position of the first and the last entry of the data structure.

Referenced by inet::physicallayer::MultiDimMappingIterator< Linear >::hasNext(), inet::physicallayer::TimeMappingIterator< Interpolator >::inRange(), inet::physicallayer::FrequencyMappingIterator< Interpolator >::inRange(), and inet::physicallayer::MultiDimMappingIterator< Linear >::inRange().

715  {
716  if (first == last)
717  return false;
718 
719  const_iterator tail = last;
720  return !(position < first->first) && !((--tail)->first < position);
721  }
used_iterator first
Definition: Interpolation.h:610
interpolator_type::const_iterator const_iterator
Definition: Interpolation.h:601
key_type position
Definition: Interpolation.h:614
used_iterator last
Definition: Interpolation.h:611
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
void inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::iterateTo ( key_cref_type  pos)
inline

forward iterates the iterator to the passed position.

This position can be any value of the Key-type.

This method assumes that the passed position is near the current position of the iterator. If this is the case this method will be faster than the jumpTo-method.

Referenced by inet::physicallayer::TimeMappingIterator< Interpolator >::iterateTo(), inet::physicallayer::FrequencyMappingIterator< Interpolator >::iterateTo(), inet::physicallayer::MultiDimMappingIterator< Linear >::iterateTo(), inet::physicallayer::TimeMappingIterator< Interpolator >::next(), and inet::physicallayer::FrequencyMappingIterator< Interpolator >::next().

674  {
675  if (pos == position)
676  return;
677 
678  while (right != last && !(pos < right->first))
679  ++right;
680 
681  position = pos;
682  }
used_iterator first
Definition: Interpolation.h:610
key_type position
Definition: Interpolation.h:614
used_iterator right
Definition: Interpolation.h:612
used_iterator last
Definition: Interpolation.h:611
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
void inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::jumpTo ( key_cref_type  pos)
inline

Moves the iterator to the passed position.

This position can be any value of the Key-type.

Referenced by inet::physicallayer::InterpolateableMap< Interpolator< std::map< simtime_t, argument_value_t > > >::findIntpl(), inet::physicallayer::TimeMappingIterator< Interpolator >::jumpTo(), inet::physicallayer::FrequencyMappingIterator< Interpolator >::jumpTo(), inet::physicallayer::MultiDimMappingIterator< Linear >::jumpTo(), and inet::physicallayer::MultiDimMappingIterator< Linear >::MultiDimMappingIterator().

640  {
641  if (pos == position)
642  return;
643 
644  if (first != last)
645  right = std::upper_bound(first, last, pos, interpolate.comp);
646 
647  position = pos;
648  }
const interpolator_type & interpolate
Definition: Interpolation.h:615
used_iterator first
Definition: Interpolation.h:610
key_type position
Definition: Interpolation.h:614
used_iterator right
Definition: Interpolation.h:612
used_iterator last
Definition: Interpolation.h:611
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
void inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::jumpToBegin ( )
inline

Moves the iterator to the first element.

Referenced by inet::physicallayer::TimeMappingIterator< Interpolator >::jumpToBegin(), inet::physicallayer::FrequencyMappingIterator< Interpolator >::jumpToBegin(), and inet::physicallayer::MultiDimMappingIterator< Linear >::jumpToBegin().

654  {
655  right = first;
656  if (right != last) {
657  position = right->first;
658  ++right;
659  }
660  else {
661  position = key_type();
662  }
663  }
interpolator_type::key_type key_type
Definition: Interpolation.h:595
used_iterator first
Definition: Interpolation.h:610
key_type position
Definition: Interpolation.h:614
used_iterator right
Definition: Interpolation.h:612
used_iterator last
Definition: Interpolation.h:611
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
void inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::next ( )
inline

Iterates to the next entry in the underlying data structure.

If the current position is before the position of the first element of the data structure this method will iterate to the first entry. If the current position is after the position of the last element of the data structure this method will increase the current position with the ++ operator.

Referenced by inet::physicallayer::TimeMappingIterator< Interpolator >::next(), inet::physicallayer::FrequencyMappingIterator< Interpolator >::next(), and inet::physicallayer::MultiDimMappingIterator< Linear >::next().

693  {
694  if (hasNext()) {
695  position = right->first;
696  ++right;
697  }
698  else
699  position += 1;
700  }
key_type position
Definition: Interpolation.h:614
used_iterator right
Definition: Interpolation.h:612
bool hasNext() const
Returns true if the a call of "next()" would increase to the position of an a valid entry of the data...
Definition: Interpolation.h:728
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
bool inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::operator== ( const ConstInterpolateableIterator< _Interpolator, _IteratorType > &  other)
inline
631  {
632  return position == other.position && right == other.right;
633  }
key_type position
Definition: Interpolation.h:614
used_iterator right
Definition: Interpolation.h:612

Member Data Documentation

template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
used_iterator inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::first
protected
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
const interpolator_type& inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::interpolate
protected
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
used_iterator inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::last
protected
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
key_type inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::position
protected
template<typename _Interpolator, typename _IteratorType = typename _Interpolator::const_iterator>
used_iterator inet::physicallayer::ConstInterpolateableIterator< _Interpolator, _IteratorType >::right
protected

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