Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

TimeMappingIterator< Interpolator > Class Template Reference
[mapping - classes representing mathematical mappings]

Provides an implementation of the MappingIterator- Interface which is able to iterate over TimeMappings. More...

#include <MappingUtils.h>

Inherits MappingIterator.

Collaboration diagram for TimeMappingIterator< Interpolator >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TimeMappingIterator (IteratorType it, bool isStepMapping)
 Initializes the Iterator to use the passed InterpolateableMapIterator.
void jumpTo (const Argument &pos)
 Lets the iterator point to the passed position.
void iterateTo (const Argument &pos)
 Iterates to the specified position. This method should be used if the new position is near the current position.
virtual void next ()
 Iterates to the next position of the function.
virtual bool inRange () const
 Returns true if the current position of the iterator is in range of the function.
virtual const ArgumentgetPosition () const
 Returns the current position of the iterator.
virtual const ArgumentgetNextPosition () const
 Returns the next position a call to "next()" would jump to.
virtual double getValue () const
 Returns the value of the function at the current position.
virtual void jumpToBegin ()
 Lets the iterator point to the begin of the mapping.
virtual bool hasNext () const
 Returns true if the iterator has a next value inside its range a call to "next()" can jump to.
virtual void setValue (double value)
 Changes the value of the function at the current position.

Protected Types

typedef std::map< simtime_t,
double > 
MapType
 The std::map the InterpolateableMap is based on.
typedef InterpolateableMap
< simtime_t, double,
Interpolator< simtime_t,
double, MapType::value_type,
MapType::const_iterator >
>::intpl_iterator 
IteratorType
 The templated InterpolateableMap the underlying Mapping uses.

Protected Member Functions

void updateNextPos ()

Protected Attributes

IteratorType valueIt
 Stores the current position iterator inside the Mapping.
Argument position
 Stores the current position of the iterator.
Argument nextPosition
 Stores the next position a call of "next()" would jump to.
bool isStepMapping
bool atPreStep

Detailed Description

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
class TimeMappingIterator< Interpolator >

Provides an implementation of the MappingIterator- Interface which is able to iterate over TimeMappings.

Author:
Karl Wessel

Definition at line 97 of file MappingUtils.h.


Member Function Documentation

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
virtual const Argument& TimeMappingIterator< Interpolator >::getNextPosition (  )  const [inline, virtual]

Returns the next position a call to "next()" would jump to.

This method has constant complexity.

Implements ConstMappingIterator.

Definition at line 219 of file MappingUtils.h.

References TimeMappingIterator< Interpolator >::nextPosition.

                                                  {
    return nextPosition;
  }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
virtual const Argument& TimeMappingIterator< Interpolator >::getPosition (  )  const [inline, virtual]

Returns the current position of the iterator.

This method has constant complexity.

Implements ConstMappingIterator.

Definition at line 210 of file MappingUtils.h.

References TimeMappingIterator< Interpolator >::position.

                                              {
    return position;
  }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
virtual double TimeMappingIterator< Interpolator >::getValue (  )  const [inline, virtual]

Returns the value of the function at the current position.

This method has constant complexity.

Implements ConstMappingIterator.

Definition at line 229 of file MappingUtils.h.

References TimeMappingIterator< Interpolator >::valueIt.

                                  {
    return *valueIt.getValue();
  }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
virtual bool TimeMappingIterator< Interpolator >::hasNext (  )  const [inline, virtual]

Returns true if the iterator has a next value inside its range a call to "next()" can jump to.

Constant complexity.

Implements ConstMappingIterator.

Definition at line 252 of file MappingUtils.h.

References TimeMappingIterator< Interpolator >::valueIt.

                                 {
      return valueIt.hasNext();
    }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
virtual bool TimeMappingIterator< Interpolator >::inRange (  )  const [inline, virtual]

Returns true if the current position of the iterator is in range of the function.

This method should be used as end-condition when iterating over the function with the "next()" method.

THis method has constant complexity.

Implements ConstMappingIterator.

Definition at line 201 of file MappingUtils.h.

References TimeMappingIterator< Interpolator >::valueIt.

                               {
    return valueIt.inRange();
  }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
void TimeMappingIterator< Interpolator >::iterateTo ( const Argument pos  )  [inline, virtual]

Iterates to the specified position. This method should be used if the new position is near the current position.

The passed position should compared bigger than the current position.

This method has linear complexity over the number of key-entries between the current position and the passed position. So if the passed position is near the current position the complexity is nearly constant.

Implements ConstMappingIterator.

Definition at line 165 of file MappingUtils.h.

References Argument::getTime(), TimeMappingIterator< Interpolator >::nextPosition, TimeMappingIterator< Interpolator >::position, Argument::setTime(), and TimeMappingIterator< Interpolator >::valueIt.

                                      {
    atPreStep = false;
    valueIt.iterateTo(pos.getTime());
    position.setTime(pos.getTime());
    nextPosition.setTime(valueIt.getNextPosition());
  }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
void TimeMappingIterator< Interpolator >::jumpTo ( const Argument pos  )  [inline, virtual]

Lets the iterator point to the passed position.

The passed new position can be at arbitrary places.

This method has logarithmic complexity.

Implements ConstMappingIterator.

Definition at line 147 of file MappingUtils.h.

References Argument::getTime(), TimeMappingIterator< Interpolator >::nextPosition, TimeMappingIterator< Interpolator >::position, Argument::setTime(), and TimeMappingIterator< Interpolator >::valueIt.

                                   {
    atPreStep = false;
    valueIt.jumpTo(pos.getTime());
    position.setTime(pos.getTime());
    nextPosition.setTime(valueIt.getNextPosition());
  }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
virtual void TimeMappingIterator< Interpolator >::jumpToBegin (  )  [inline, virtual]

Lets the iterator point to the begin of the mapping.

The beginning of the mapping is the smallest key entry in the InterpolateableMap.

Constant complexity.

Implements ConstMappingIterator.

Definition at line 241 of file MappingUtils.h.

References TimeMappingIterator< Interpolator >::position, Argument::setTime(), and TimeMappingIterator< Interpolator >::valueIt.

                             {
    valueIt.jumpToBegin();
    position.setTime(valueIt.getPosition());
  }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
virtual void TimeMappingIterator< Interpolator >::next (  )  [inline, virtual]

Iterates to the next position of the function.

The next position is the next bigger key entry of the InterpoalteableMap.

This method has constant complexity.

Implements ConstMappingIterator.

Definition at line 180 of file MappingUtils.h.

References Argument::getTime(), TimeMappingIterator< Interpolator >::nextPosition, TimeMappingIterator< Interpolator >::position, Argument::setTime(), and TimeMappingIterator< Interpolator >::valueIt.

                      {
    if(isStepMapping && !atPreStep){
      valueIt.iterateTo(nextPosition.getTime());
      atPreStep = true;
    } else {
      valueIt.next();
      atPreStep = false;
    }
    position.setTime(valueIt.getPosition());
    updateNextPos();
  }

template<template< class Key, class Value, class Pair, class Iterator > class Interpolator>
virtual void TimeMappingIterator< Interpolator >::setValue ( double  value  )  [inline, virtual]

Changes the value of the function at the current position.

THis method has constant complexity.

Implements MappingIterator.

Definition at line 262 of file MappingUtils.h.

References TimeMappingIterator< Interpolator >::valueIt.

                                      {
    valueIt.setValue(value);
  }


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