25#ifndef quantlib_timeseries_hpp
26#define quantlib_timeseries_hpp
32#include <boost/iterator/transform_iterator.hpp>
50 template <
class T,
class Container = std::map<Date, T> >
64 template <
class DateIterator,
class ValueIterator>
66 ValueIterator vBegin) {
67 while (dBegin != dEnd)
68 values_[*(dBegin++)] = *(vBegin++);
75 template <
class ValueIterator>
77 ValueIterator
begin, ValueIterator
end) {
97 typename Container::const_iterator found =
values_.find(
d);
100 return found->second;
104 return found->second;
119 template <
class container,
class iterator_category>
121 typedef std::reverse_iterator<typename container::const_iterator>
135 template <
class container>
137 typedef typename container::const_reverse_iterator
147 typedef std::conditional_t<
148 std::is_same<iterator_category, std::bidirectional_iterator_tag>::value ||
149 std::is_base_of<std::bidirectional_iterator_tag, iterator_category>::value,
184 [[deprecated(
"Use const_iterator instead and access the `first` data member.")]]
190 [[deprecated(
"Use const_iterator instead and access the `second` data member.")]]
196 [[deprecated(
"Use const_reverse_iterator instead and access the `first` data member.")]]
202 [[deprecated(
"Use const_reverse_iterator instead and access the `second` data member.")]]
210 [[deprecated(
"Use cbegin instead and access the `second` data member.")]]
218 [[deprecated(
"Use cend instead and access the `second` data member.")]]
226 [[deprecated(
"Use crbegin instead and access the `second` data member.")]]
234 [[deprecated(
"Use crend instead and access the `second` data member.")]]
242 [[deprecated(
"Use cbegin instead and access the `first` data member.")]]
250 [[deprecated(
"Use cend instead and access the `first` data member.")]]
258 [[deprecated(
"Use crbegin instead and access the `first` data member.")]]
266 [[deprecated(
"Use crend instead and access the `first` data member.")]]
294 template <
class T,
class C>
296 QL_REQUIRE(!values_.empty(),
"empty timeseries");
297 return values_.begin()->first;
300 template <
class T,
class C>
302 QL_REQUIRE(!values_.empty(),
"empty timeseries");
303 return rbegin()->first;
306 template <
class T,
class C>
308 return values_.size();
311 template <
class T,
class C>
313 return values_.empty();
316 template <
class T,
class C>
319 return values_.begin();
322 template <
class T,
class C>
325 return values_.end();
328 template <
class T,
class C>
332 if (i == values_.end()) {
339 template <
class T,
class C>
343 std::transform(cbegin(), cend(), std::back_inserter(
v),
348 template <
class T,
class C>
352 std::transform(cbegin(), cend(), std::back_inserter(
v),
template class providing a null value for a given type.
Container for historical data.
static const Date & get_time(const container_value_type &v)
const_reverse_iterator rend() const
Container::const_iterator const_iterator
const_value_iterator cend_values() const
reverse< Container, enable_reverse >::const_reverse_iterator const_reverse_iterator
const_reverse_time_iterator crend_time() const
ext::function< T(const container_value_type &)> projection_value
boost::transform_iterator< projection_time, const_reverse_iterator > const_reverse_time_iterator
const_iterator::iterator_category iterator_category
const_iterator begin() const
const_iterator find(const Date &)
std::conditional_t< std::is_same< iterator_category, std::bidirectional_iterator_tag >::value||std::is_base_of< std::bidirectional_iterator_tag, iterator_category >::value, std::bidirectional_iterator_tag, std::input_iterator_tag > enable_reverse
const_iterator cbegin() const
const_reverse_time_iterator crbegin_time() const
TimeSeries(DateIterator dBegin, DateIterator dEnd, ValueIterator vBegin)
const_reverse_value_iterator crbegin_values() const
std::vector< T > values() const
returns the historical data
ext::function< Date(const container_value_type &)> projection_time
Container::value_type container_value_type
bool empty() const
returns whether the series contains any data
boost::transform_iterator< projection_value, const_reverse_iterator > const_reverse_value_iterator
T & operator[](const Date &d)
const_iterator cend() const
const_reverse_value_iterator crend_values() const
const_reverse_iterator crbegin() const
TimeSeries(const Date &firstDate, ValueIterator begin, ValueIterator end)
std::vector< Date > dates() const
returns the dates for which historical data exist
Date firstDate() const
returns the first date for which a historical datum exists
boost::transform_iterator< projection_value, const_iterator > const_value_iterator
Date lastDate() const
returns the last date for which a historical datum exists
const_reverse_iterator crend() const
const_time_iterator cbegin_time() const
QL_DEPRECATED_DISABLE_WARNING const_value_iterator cbegin_values() const
static const T & get_value(const container_value_type &v)
Size size() const
returns the number of historical data including null ones
const_iterator end() const
T operator[](const Date &d) const
returns the (possibly null) datum corresponding to the given date
boost::transform_iterator< projection_time, const_iterator > const_time_iterator
const_time_iterator cend_time() const
const_reverse_iterator rbegin() const
date- and time-related classes, typedefs and enumerations
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Maps function, bind and cref to either the boost or std implementation.
std::size_t Size
size of a container
ext::shared_ptr< BlackVolTermStructure > v
#define QL_DEPRECATED_DISABLE_WARNING
#define QL_DEPRECATED_ENABLE_WARNING
const_reverse_iterator rend() const
container::const_reverse_iterator const_reverse_iterator
reverse(const container &c)
const_reverse_iterator rbegin() const
const_reverse_iterator rend() const
std::reverse_iterator< typename container::const_iterator > const_reverse_iterator
reverse(const container &c)
const_reverse_iterator rbegin() const