/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb Copyright (C) 2005, 2006 StatPro Italia srl This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ QuantLib is free software: you can redistribute it and/or modify it under the terms of the QuantLib license. You should have received a copy of the license along with this program; if not, please email . The license is also available online at . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /*! \file timegrid.hpp \brief discrete time grid */ #ifndef quantlib_time_grid_hpp #define quantlib_time_grid_hpp #include #include #include #include namespace QuantLib { //! time grid class /*! \todo what was the rationale for limiting the grid to positive times? Investigate and see whether we can use it for negative ones as well. */ class TimeGrid { public: //! \name Constructors //@{ TimeGrid() {} //! Regularly spaced time-grid TimeGrid(Time end, Size steps); //! Time grid with mandatory time points /*! Mandatory points are guaranteed to belong to the grid. No additional points are added. */ template TimeGrid(Iterator begin, Iterator end) #if defined(QL_FULL_ITERATOR_SUPPORT) : mandatoryTimes_(begin, end) { #else { while (begin != end) mandatoryTimes_.push_back(*(begin++)); #endif std::sort(mandatoryTimes_.begin(),mandatoryTimes_.end()); // We seem to assume that the grid begins at 0. // Let's enforce the assumption for the time being // (even though I'm not sure that I agree.) QL_REQUIRE(mandatoryTimes_.front() >= 0.0, "negative times not allowed"); std::vector