nemo::TimeSeries< TimestampType, ValueType, strictOrdering > Class Template Reference

Represents a temporal series of values of type ValueType. More...

#include <TimeSeries.h>

List of all members.

Classes

class  TimestampView
 This class represents a view on the timestamps within one timeseries. More...
class  ValueView
 This class represents a view on the values within one timeseries. More...

Public Types

typedef TimeSeries
< TimestampType, ValueType,
strictOrdering > 
ThisType
typedef TimeSeriesEntry
< TimestampType, ValueType > 
EntryType

Public Member Functions

typedef _nemo_get_type_ (TimestampType()-TimestampType()) DurationType
 TimeSeries ()
 TimeSeries (const ThisType &o)
TimeSeries< TimestampType,
ValueType, strictOrdering > & 
operator= (const ThisType &o)
unsigned int length () const
 Returns the number of entries in the TimeSeries.
bool isEmpty () const
 Returns true iff length()==0.
ValueType operator[] (TimestampType timeP) const
 Returns the value associated to the specified timestamp.
void append (TimestampType timeP, ValueType valueP)
 Appends a new entry to the TimeSeries.
void append (const TimeOffset< DurationType > &offset, ValueType valueP)
 Appends a new entry to the TimeSeries.
void append (ThisType otherSeries)
 Appends the entries of another series to this one.
void append (const TimeOffset< DurationType > &offset, ThisType otherSeries)
 Appends the entries of another series to this one.
void setValue (TimestampType timeP, ValueType valueP)
 Sets a new value for an existing timestamp.
void insert (TimestampType timeP, ValueType valueP)
 Inserts a new entry into the timeseries.
void remove (TimestampType timeP)
 Removes the entry with the specified timestamp.
void removeFirst ()
 Removes the entry with the smallest timestamp.
void removeFirst (unsigned int k)
 Removes the k entries with the smallest timestamps.
bool operator== (const ThisType &r) const
 Returns true if dimensions and all contained values are equal (i.e.
bool operator!= (const ThisType &r) const
 ! operator==
unsigned int numElements () const
EntryType getElement (unsigned int elementIndex) const
void setElement (unsigned int elementIndex, EntryType entry)
 Change the value of an element.
void transform (Mapping< EntryType, EntryType > m)
template<typename OtherTimestampType , typename OtherValueType >
TimeSeries< OtherTimestampType,
OtherValueType, strictOrdering > 
map (Mapping< EntryType, TimeSeriesEntry< OtherTimestampType, OtherValueType > > m) const
EntryIterator begin () const
 Returns an STL-compliant (read-only) iterator pointing to the first value.
EntryIterator end () const
 Returns an STL-compliant (read-only) iterator pointing one position after the last element.

Public Attributes

TimestampView timestamps
 View on the timestamps within the series.
ValueView values
 View on the values within the series.

Detailed Description

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
class nemo::TimeSeries< TimestampType, ValueType, strictOrdering >

Represents a temporal series of values of type ValueType.

Each value is associated to a timestamp (of type TimestampType), which can be used to address the value.

Both values and timestamps can also be accessed in an index-based manner using the public members values and timestamps. The ordering of that indexing corresponds to an ordered list of the timestamps.

The third template argument strictOrdering allows to require a strict 'smaller than' relation in the ordering of timestamps. If it is set to true, the TimeSeries will throw std::invalid_argument whenever two timestamps in the series would become equal, such that a strict ordering is impossible. By default strictOrdering is set to false.

Write operations are generally permitted to change the ordering of timestamps. They will automatically be re-sorted, and the values are re-ordered accordingly such that the original timestamp->value association is maintained.

Definition at line 94 of file TimeSeries.h.


Member Typedef Documentation

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
typedef TimeSeriesEntry<TimestampType,ValueType> nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::EntryType

Definition at line 98 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
typedef TimeSeries<TimestampType,ValueType,strictOrdering> nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::ThisType

Definition at line 97 of file TimeSeries.h.


Constructor & Destructor Documentation

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::TimeSeries (  )  [inline]

Definition at line 507 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::TimeSeries ( const ThisType o  )  [inline]

Definition at line 508 of file TimeSeries.h.


Member Function Documentation

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
typedef nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::_nemo_get_type_ ( TimestampType()-TimestampType()   ) 
template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::append ( const TimeOffset< DurationType > &  offset,
ThisType  otherSeries 
) [inline]

Appends the entries of another series to this one.

Before adding them, this method shifts the timestamps of the other series such that the difference between the last element of this series and the first element of the other series will be exactly offset.

Definition at line 600 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::append ( ThisType  otherSeries  )  [inline]

Appends the entries of another series to this one.

An invalid_argument exception will be thrown if the timestamps are not in a valid ordering.

Definition at line 584 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::append ( const TimeOffset< DurationType > &  offset,
ValueType  valueP 
) [inline]

Appends a new entry to the TimeSeries.

The timestamp will be

  • timestamps(length()-1)+offset if the series already contains entries
  • TimestampType()+offset if the series is empty

Usage:

series.append(offset(offsetValue), value) 

Runtime: O(1)

Definition at line 570 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::append ( TimestampType  timeP,
ValueType  valueP 
) [inline]

Appends a new entry to the TimeSeries.

An invalid_argument exception will be thrown if the timestamp-ordering does not allow to place this timestamp at the end of the series.

Runtime: O(1)

Definition at line 554 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
EntryIterator nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::begin (  )  const [inline]

Returns an STL-compliant (read-only) iterator pointing to the first value.

Definition at line 859 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
EntryIterator nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::end (  )  const [inline]

Returns an STL-compliant (read-only) iterator pointing one position after the last element.

Definition at line 865 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
EntryType nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::getElement ( unsigned int  elementIndex  )  const [inline, virtual]
Parameters:
elementIndex between zero and numElements()-1
Returns:
Respective element in collection

Implements nemo::Collection< TimeSeriesEntry< TimestampType, ValueType > >.

Definition at line 727 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::insert ( TimestampType  timeP,
ValueType  valueP 
) [inline]

Inserts a new entry into the timeseries.

If strictOrdering==false this operation will never throw. If strictOrdering is enabled it will throw invalid_argument if the timestamp already exists.

Runtime: o(log(n)); O(n)

Definition at line 633 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
bool nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::isEmpty (  )  const [inline]

Returns true iff length()==0.

Definition at line 529 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
unsigned int nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::length (  )  const [inline]

Returns the number of entries in the TimeSeries.

Definition at line 524 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
template<typename OtherTimestampType , typename OtherValueType >
TimeSeries<OtherTimestampType,OtherValueType,strictOrdering> nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::map ( Mapping< EntryType, TimeSeriesEntry< OtherTimestampType, OtherValueType > >  m  )  const [inline]

Definition at line 759 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
unsigned int nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::numElements (  )  const [inline, virtual]
Returns:
Number of elements in a collection

Implements nemo::Collection< TimeSeriesEntry< TimestampType, ValueType > >.

Definition at line 719 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
bool nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::operator!= ( const ThisType r  )  const [inline]

! operator==

Definition at line 712 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
TimeSeries<TimestampType,ValueType,strictOrdering>& nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::operator= ( const ThisType o  )  [inline]

Definition at line 509 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
bool nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::operator== ( const ThisType r  )  const [inline]

Returns true if dimensions and all contained values are equal (i.e.

exactly equal in terms of T::operator==(T&) ).

Definition at line 693 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
ValueType nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::operator[] ( TimestampType  timeP  )  const [inline]

Returns the value associated to the specified timestamp.

If the timestamp is not (exactly) contained in the TimeSeries, an invalid_argument exception will be thrown.

Runtime: O(log(n))

Definition at line 539 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::remove ( TimestampType  timeP  )  [inline]

Removes the entry with the specified timestamp.

Runtime: o(log(n)); O(n)

Definition at line 654 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::removeFirst ( unsigned int  k  )  [inline]

Removes the k entries with the smallest timestamps.

Runtime: O(n)

Definition at line 679 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::removeFirst (  )  [inline]

Removes the entry with the smallest timestamp.

Runtime: O(n)

Definition at line 668 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::setElement ( unsigned int  elementIndex,
EntryType  entry 
) [inline]

Change the value of an element.

Parameters:
elementIndex between zero and numElements()-1
value New value for respective element

Definition at line 737 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::setValue ( TimestampType  timeP,
ValueType  valueP 
) [inline]

Sets a new value for an existing timestamp.

If the timestamp is not (exactly) contained in the TimeSeries, an invalid_argument exception will be thrown.

Runtime: O(log(n))

Definition at line 621 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
void nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::transform ( Mapping< EntryType, EntryType m  )  [inline]

Definition at line 743 of file TimeSeries.h.


Member Data Documentation

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
TimestampView nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::timestamps

View on the timestamps within the series.

Definition at line 491 of file TimeSeries.h.

template<typename TimestampType, typename ValueType, bool strictOrdering = false>
ValueView nemo::TimeSeries< TimestampType, ValueType, strictOrdering >::values

View on the values within the series.

Definition at line 495 of file TimeSeries.h.


The documentation for this class was generated from the following file:
Generated on Mon Feb 25 12:49:59 2013 for NemoMath by  doxygen 1.6.3