# closestTime (3) - Linux Manuals

## closestTime: time grid class

## NAME

QuantLib::TimeGrid - time grid class

## SYNOPSIS

#include <ql/timegrid.hpp>

### Public Member Functions

**Constructors**

**TimeGrid** ()

**TimeGrid** (**Time** end, Size steps)

*Regularly spaced time-grid. *

template<class Iterator > **TimeGrid** (Iterator begin, Iterator end)

*Time grid with mandatory time points. *

template<class Iterator > **TimeGrid** (Iterator begin, Iterator end, Size steps)

*Time grid with mandatory time points. *

**Time grid interface**

Size **index** (**Time** t) const

*returns the index i such that grid[i] = t *

Size **closestIndex** (**Time** t) const

*returns the index i such that grid[i] is closest to t *

**Time** **closestTime** (**Time** t) const

*returns the time on the grid closest to the given t *

const std::vector< **Time** > & **mandatoryTimes** () const

**Time** **dt** (Size i) const

### sequence interface

typedef std::vector< **Time** >::const_iterator **const_iterator**

typedef std::vector< **Time** >::const_reverse_iterator **const_reverse_iterator**

**Time** **operator[]** (Size i) const

**Time** **at** (Size i) const

Size **size** () const

bool **empty** () const

const_iterator **begin** () const

const_iterator **end** () const

const_reverse_iterator **rbegin** () const

const_reverse_iterator **rend** () const

**Time** **front** () const

**Time** **back** () const

## Detailed Description

time grid class

**Possible enhancements**

- what was the rationale for limiting the grid to positive times? Investigate and see whether we can use it for negative ones as well.

**Examples: **

## Constructor & Destructor Documentation

**TimeGrid** (Iterator begin, Iterator end)

Time grid with mandatory time points.

Mandatory points are guaranteed to belong to the grid. No additional points are added.

**TimeGrid** (Iterator begin, Iterator end, Size steps)

Time grid with mandatory time points.

Mandatory points are guaranteed to belong to the grid. Additional points are then added with regular spacing between pairs of mandatory times in order to reach the desired number of steps.

## Author

Generated automatically by Doxygen for QuantLib from the source code.