History Class Reference

#include <ql/history.hpp>

List of all members.


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 filtering_iterator<
const_iterator, DataValidator > 
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 filtering_iterator<
const_data_iterator, DataValidator > 
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 DatefirstDate () const
 returns the first date for which a historical datum exists

const DatelastDate () 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


Constructor & Destructor Documentation

History  ) 
 

Default constructor

History const Date firstDate,
const Date lastDate,
Iterator  begin,
Iterator  end
 

This constructor initializes the history with the given set of values, corresponding to the date range between firstDate and lastDate included.

Precondition:
begin-end must equal the number of days from firstDate to lastDate included.

History const Date firstDate,
const Date lastDate,
const std::vector< Real > &  values
 

This constructor initializes the history with the given set of values, corresponding to the date range between firstDate and lastDate included.

Precondition:
The size of values must equal the number of days from firstDate to lastDate included.

History const std::vector< Date > &  dates,
const std::vector< Real > &  values
 

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.

Precondition:
dates must be sorted.

There can be no pairs (dates[i],values[i]) and (dates[j],values[j]) such that dates[i] == dates[j] && values[i] != values[j]. Pairs with dates[i] == dates[j] && values[i] == values[j] are allowed; the duplicated entries will be discarded.

The size of values must equal the number of days from firstDate to lastDate included.


QuantLib.org
QuantLib
Hosted by
SourceForge.net Logo
Documentation generated by
doxygen