History Class Reference
#include <ql/history.hpp>
Detailed Description
Container for historical data.This class acts as a generic repository for a set of historical data. Single data can be accessed through their date, while sets of consecutive data can be accessed through iterators.
A history can contain null data, which can either be returned or skipped according to the chosen iterator type.
Example: uses of history iterators
Public Types | |
typedef boost::filter_iterator< DataValidator, const_iterator > | const_valid_iterator |
bidirectional iterator on non-null history entries | |
typedef std::vector< Real >::const_iterator | const_data_iterator |
random access iterator on historical data | |
typedef boost::filter_iterator< DataValidator, const_data_iterator > | const_valid_data_iterator |
bidirectional iterator on non-null historical data | |
Public Member Functions | |
History () | |
template<class Iterator> | |
History (const Date &firstDate, const Date &lastDate, Iterator begin, Iterator end) | |
History (const Date &firstDate, const std::vector< Real > &values) | |
History (const Date &firstDate, const Date &lastDate, const std::vector< Real > &values) | |
History (const std::vector< Date > &dates, const std::vector< Real > &values) | |
Inspectors | |
const Date & | firstDate () const |
returns the first date for which a historical datum exists | |
const Date & | lastDate () const |
returns the last date for which a historical datum exists | |
Size | size () const |
returns the number of historical data including null ones | |
Historical data access | |
Real | operator[] (const Date &) const |
returns the (possibly null) datum corresponding to the given date | |
Iterator access | |
Four different types of iterators are provided, namely, const_iterator, const_valid_iterator, const_data_iterator, and const_valid_data_iterator.
const_iterator and const_valid_iterator point to an Entry structure, the difference being that the latter only iterates over valid entries - i.e., entries whose data are not null. The same difference exists between const_data_iterator and const_valid_data_iterator which point directly to historical values without reference to the date they are associated to. | |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | iterator (const Date &d) const |
const_valid_iterator | vbegin () const |
const_valid_iterator | vend () const |
const_valid_iterator | valid_iterator (const Date &d) const |
const_data_iterator | dbegin () const |
const_data_iterator | dend () const |
const_data_iterator | data_iterator (const Date &d) const |
const_valid_data_iterator | vdbegin () const |
const_valid_data_iterator | vdend () const |
const_valid_data_iterator | valid_data_iterator (const Date &d) const |
Classes | |
class | const_iterator |
random access iterator on history entries More... | |
class | Entry |
single datum in history More... |
Constructor & Destructor Documentation
|
Default constructor |
|
This constructor initializes the history with the given set of values, corresponding to the date range between firstDate and lastDate included.
|
|
This constructor initializes the history with the given set of values, corresponding to the date range between firstDate and lastDate included.
|
|
This constructor initializes the history with the given set of values, corresponding each to the element with the same index in the given set of dates. The whole date range between dates[0] and dates[N-1] will be automatically filled by inserting null values where a date is missing from the given set.
|