Curves
A library for curves generation.
curves::LocalSupport2CoefficientManager< Coefficient > Class Template Reference

#include <LocalSupport2CoefficientManager.hpp>

Classes

struct  KeyCoefficient
 

Public Types

typedef Coefficient CoefficientType
 
typedef std::map< Time, KeyCoefficientTimeToKeyCoefficientMap
 
typedef TimeToKeyCoefficientMap::const_iterator CoefficientIter
 
typedef boost::unordered_map< size_t, CoefficientCoefficientMap
 Key/Coefficient pairs. More...
 

Public Member Functions

 LocalSupport2CoefficientManager ()
 
virtual ~LocalSupport2CoefficientManager ()
 
bool equals (const LocalSupport2CoefficientManager &other, double tol=1e-9) const
 Compare this Coefficient manager with another for equality. More...
 
void print (const std::string &str="") const
 Print the value of the coefficient, for debugging and unit tests. More...
 
void getKeys (std::vector< Key > *outKeys) const
 
void appendKeys (std::vector< Key > *outKeys) const
 
void getTimes (std::vector< Time > *outTimes) const
 Get a sorted list of coefficient times. More...
 
void getTimesInWindow (std::vector< Time > *outTimes, Time begTime, Time endTime) const
 Get a sorted list of coefficient times in a given time window. More...
 
void modifyCoefficientsValuesInBatch (const std::vector< Time > &times, const std::vector< Coefficient > &values)
 Modify multiple coefficient values. Time is assumed to be ordered. More...
 
Key insertCoefficient (Time time, const Coefficient &coefficient)
 insert a coefficient at a time and return the key for the coefficient More...
 
void insertCoefficients (const std::vector< Time > &times, const std::vector< Coefficient > &values, std::vector< Key > *outKeys=NULL)
 Insert coefficients. Optionally returns the keys for these coefficients. More...
 
void addCoefficientAtEnd (Time time, const Coefficient &coefficient, std::vector< Key > *outKeys=NULL)
 Efficient function for adding a coefficient at the end of the map. More...
 
void modifyCoefficient (typename TimeToKeyCoefficientMap::iterator it, Time time, const Coefficient &coefficient)
 Modify a coefficient by specifying a new time and value. More...
 
void removeCoefficientWithKey (Key key)
 Remove the coefficient with this key. More...
 
void removeCoefficientAtTime (Time time)
 Remove the coefficient at this time. More...
 
bool hasCoefficientAtTime (Time time) const
 return true if there is a coefficient at this time More...
 
bool hasCoefficientWithKey (Key key) const
 return true if there is a coefficient with this key More...
 
void updateCoefficientByKey (Key key, const Coefficient &coefficient)
 set the coefficient associated with this key More...
 
Coefficient getCoefficientByKey (Key key) const
 set the coefficient associated with this key More...
 
Time getCoefficientTimeByKey (Key key) const
 get the coefficient time associated with this key More...
 
bool getCoefficientsAt (Time time, CoefficientIter *outCoefficient0, CoefficientIter *outCoefficient1) const
 Get the coefficients that are active at a certain time. More...
 
void getCoefficientsInRange (Time startTime, Time endTime, CoefficientMap *outCoefficients) const
 Get the coefficients that are active within a range $[t_s,t_e) $. More...
 
void getCoefficients (CoefficientMap *outCoefficients) const
 Get all of the curve's coefficients. More...
 
void updateCoefficients (const CoefficientMap &coefficients)
 Set coefficients. More...
 
size_t size () const
 return the number of coefficients More...
 
bool empty () const
 Check if the manager is empty. More...
 
void clear ()
 clear the coefficients More...
 
Time getMinTime () const
 The first valid time for the curve. More...
 
Time getMaxTime () const
 The one past the last valid time for the curve. More...
 
CoefficientIter coefficientBegin () const
 
CoefficientIter coefficientEnd () const
 
TimeToKeyCoefficientMap::iterator coefficientBegin ()
 
TimeToKeyCoefficientMap::iterator coefficientEnd ()
 
void checkInternalConsistency (bool doExit=false) const
 

Private Member Functions

bool hasCoefficientAtTime (Time time, CoefficientIter *it, double tol=0)
 

Private Attributes

boost::unordered_map< Key, CoefficientIterkeyToCoefficient_
 Key to coefficient mapping. More...
 
TimeToKeyCoefficientMap timeToCoefficient_
 Time to coefficient mapping. More...
 

Detailed Description

template<class Coefficient>
class curves::LocalSupport2CoefficientManager< Coefficient >

Definition at line 22 of file LocalSupport2CoefficientManager.hpp.

Member Typedef Documentation

template<class Coefficient>
typedef TimeToKeyCoefficientMap::const_iterator curves::LocalSupport2CoefficientManager< Coefficient >::CoefficientIter

Definition at line 48 of file LocalSupport2CoefficientManager.hpp.

template<class Coefficient>
typedef boost::unordered_map<size_t, Coefficient> curves::LocalSupport2CoefficientManager< Coefficient >::CoefficientMap

Key/Coefficient pairs.

Definition at line 50 of file LocalSupport2CoefficientManager.hpp.

Definition at line 47 of file LocalSupport2CoefficientManager.hpp.

Constructor & Destructor Documentation

Member Function Documentation

template<class Coefficient>
void curves::LocalSupport2CoefficientManager< Coefficient >::addCoefficientAtEnd ( Time  time,
const Coefficient coefficient,
std::vector< Key > *  outKeys = NULL 
)

Efficient function for adding a coefficient at the end of the map.

Definition at line 165 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::appendKeys ( std::vector< Key > *  outKeys) const

Get all of the keys in this manager. The list is not cleared before pushing it to the container.

Definition at line 66 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::checkInternalConsistency ( bool  doExit = false) const

Check the internal consistency of the data structure If doExit is true, the function will call exit(0) at the end. This is useful for gtest death tests

Definition at line 376 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::clear ( )

clear the coefficients

Definition at line 354 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient>
CoefficientIter curves::LocalSupport2CoefficientManager< Coefficient >::coefficientBegin ( ) const
inline

Definition at line 168 of file LocalSupport2CoefficientManager.hpp.

template<class Coefficient>
TimeToKeyCoefficientMap::iterator curves::LocalSupport2CoefficientManager< Coefficient >::coefficientBegin ( )
inline

Definition at line 176 of file LocalSupport2CoefficientManager.hpp.

template<class Coefficient>
CoefficientIter curves::LocalSupport2CoefficientManager< Coefficient >::coefficientEnd ( ) const
inline

Definition at line 172 of file LocalSupport2CoefficientManager.hpp.

template<class Coefficient>
TimeToKeyCoefficientMap::iterator curves::LocalSupport2CoefficientManager< Coefficient >::coefficientEnd ( )
inline

Definition at line 180 of file LocalSupport2CoefficientManager.hpp.

template<class Coefficient >
bool curves::LocalSupport2CoefficientManager< Coefficient >::empty ( ) const

Check if the manager is empty.

Definition at line 348 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
bool curves::LocalSupport2CoefficientManager< Coefficient >::equals ( const LocalSupport2CoefficientManager< Coefficient > &  other,
double  tol = 1e-9 
) const

Compare this Coefficient manager with another for equality.

Definition at line 28 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
Coefficient curves::LocalSupport2CoefficientManager< Coefficient >::getCoefficientByKey ( Key  key) const

set the coefficient associated with this key

get the coefficient associated with this key

Definition at line 241 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::getCoefficients ( CoefficientMap outCoefficients) const

Get all of the curve's coefficients.

Definition at line 319 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
bool curves::LocalSupport2CoefficientManager< Coefficient >::getCoefficientsAt ( Time  time,
CoefficientIter outCoefficient0,
CoefficientIter outCoefficient1 
) const

Get the coefficients that are active at a certain time.

This method can fail if the time is out of bounds. If it Succeeds, the elements of the pair are guaranteed to be filled nonnull.

Returns
true if it was successful

Definition at line 256 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::getCoefficientsInRange ( Time  startTime,
Time  endTime,
CoefficientMap outCoefficients 
) const

Get the coefficients that are active within a range $[t_s,t_e) $.

Definition at line 290 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
Time curves::LocalSupport2CoefficientManager< Coefficient >::getCoefficientTimeByKey ( Key  key) const

get the coefficient time associated with this key

Definition at line 247 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::getKeys ( std::vector< Key > *  outKeys) const

Get all of the keys in this manager. This method clears the list of keys before filling it.

Definition at line 59 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
Time curves::LocalSupport2CoefficientManager< Coefficient >::getMaxTime ( ) const

The one past the last valid time for the curve.

Definition at line 368 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
Time curves::LocalSupport2CoefficientManager< Coefficient >::getMinTime ( ) const

The first valid time for the curve.

Definition at line 360 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::getTimes ( std::vector< Time > *  outTimes) const

Get a sorted list of coefficient times.

Definition at line 77 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::getTimesInWindow ( std::vector< Time > *  outTimes,
Time  begTime,
Time  endTime 
) const

Get a sorted list of coefficient times in a given time window.

Definition at line 89 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
bool curves::LocalSupport2CoefficientManager< Coefficient >::hasCoefficientAtTime ( Time  time) const

return true if there is a coefficient at this time

Definition at line 216 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
bool curves::LocalSupport2CoefficientManager< Coefficient >::hasCoefficientAtTime ( Time  time,
CoefficientIter it,
double  tol = 0 
)
private

Definition at line 401 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
bool curves::LocalSupport2CoefficientManager< Coefficient >::hasCoefficientWithKey ( Key  key) const

return true if there is a coefficient with this key

Definition at line 223 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient>
Key curves::LocalSupport2CoefficientManager< Coefficient >::insertCoefficient ( Time  time,
const Coefficient coefficient 
)

insert a coefficient at a time and return the key for the coefficient

If a coefficient with this time already exists, it is overwritten

Definition at line 114 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient>
void curves::LocalSupport2CoefficientManager< Coefficient >::insertCoefficients ( const std::vector< Time > &  times,
const std::vector< Coefficient > &  values,
std::vector< Key > *  outKeys = NULL 
)

Insert coefficients. Optionally returns the keys for these coefficients.

insert coefficients. Optionally returns the keys for these coefficients

If outKeys is not NULL, this function will not check if it is empty; new keys will be appended to this vector.

Definition at line 133 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient>
void curves::LocalSupport2CoefficientManager< Coefficient >::modifyCoefficient ( typename TimeToKeyCoefficientMap::iterator  it,
Time  time,
const Coefficient coefficient 
)

Modify a coefficient by specifying a new time and value.

Definition at line 181 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient>
void curves::LocalSupport2CoefficientManager< Coefficient >::modifyCoefficientsValuesInBatch ( const std::vector< Time > &  times,
const std::vector< Coefficient > &  values 
)

Modify multiple coefficient values. Time is assumed to be ordered.

Definition at line 147 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::print ( const std::string &  str = "") const

Print the value of the coefficient, for debugging and unit tests.

Definition at line 109 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::removeCoefficientAtTime ( Time  time)

Remove the coefficient at this time.

It is an error if there is no coefficient at this time.

Definition at line 204 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::removeCoefficientWithKey ( Key  key)

Remove the coefficient with this key.

It is an error if the key does not exist.

Definition at line 193 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
Key curves::LocalSupport2CoefficientManager< Coefficient >::size ( ) const

return the number of coefficients

Definition at line 343 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient>
void curves::LocalSupport2CoefficientManager< Coefficient >::updateCoefficientByKey ( Key  key,
const Coefficient coefficient 
)

set the coefficient associated with this key

This function fails if there is no coefficient associated with this key.

Definition at line 233 of file LocalSupport2CoefficientManager-inl.hpp.

template<class Coefficient >
void curves::LocalSupport2CoefficientManager< Coefficient >::updateCoefficients ( const CoefficientMap coefficients)

Set coefficients.

If any of these coefficients doen't exist, there is an error

Definition at line 332 of file LocalSupport2CoefficientManager-inl.hpp.

Member Data Documentation

template<class Coefficient>
boost::unordered_map<Key, CoefficientIter> curves::LocalSupport2CoefficientManager< Coefficient >::keyToCoefficient_
private

Key to coefficient mapping.

Definition at line 191 of file LocalSupport2CoefficientManager.hpp.

template<class Coefficient>
TimeToKeyCoefficientMap curves::LocalSupport2CoefficientManager< Coefficient >::timeToCoefficient_
private

Time to coefficient mapping.

Definition at line 194 of file LocalSupport2CoefficientManager.hpp.


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