#include "datelist.h"
Functions | |
TDateList * | JpmcdsDateListAddDates (TDateList *dl, int numItems, TDate *array) |
Adds dates to a TDateList. | |
TDateList * | JpmcdsDateListAddDatesFreeOld (TDateList *dl, int numItems, TDate *array) |
Adds dates to a TDateList and frees the input date list. | |
TDateList * | JpmcdsDateListTruncate (TDateList *dateList, TDate truncationDate, TBoolean inclusive, TBoolean excludeBefore, TBoolean inPlace) |
Truncates a date list at the specified date. | |
TDateList * | JpmcdsDateListMakeRegular (TDate startDate, TDate endDate, TDateInterval *interval, TStubMethod *stubType) |
Adds dates to a TDateList.
If the original date list and date list to be added are sorted, then the resulting date list will be sorted and duplicate dates will be removed. Sorting assumes ascending order ([0] < [1] etc).
If either of the inputs are not sorted, then the resulting date list will not be sorted, and some duplicates may remain.
For efficiency, we do not automatically try to sort the resulting date list for unsorted inputs. Sorting the date list each time appears to be a huge performance issue in some algorithms (where the input dates would all be sorted anyway).
Note that if dl is NULL, then this will create a new date list from the given dates.
Note that if numItems=0, this will copy the given date list.
Adds dates to a TDateList and frees the input date list.
If the original date list and date list to be added are sorted, then the resulting date list will be sorted and duplicate dates will be removed. Sorting assumes ascending order ([0] < [1] etc).
If either of the inputs are not sorted, then the resulting date list will not be sorted, and some duplicates may remain.
For efficiency, we do not automatically try to sort the resulting date list for unsorted inputs. Sorting the date list each time appears to be a huge performance issue in some algorithms (where the input dates would all be sorted anyway).
Note that if dl is NULL, then this will create a new date list from the given dates.
Note that if numItems=0, this will copy the given date list.
The input date list is FREE'd by this routine. Thus if you have an algorithm which involves building up a datelist gradually, you can do something like this:
TDateList* dl = NULL; ... dl = JpmcdsDateListAddDatesFreeOld (dl, numItems, array); if (dl == NULL) goto done; .. dl = JpmcdsDateListAddDatesFreeOld (dl, numItems, array); if (dl == NULL) goto done; .. etc.
with the point being that you don't have to worry about the original date list at each step since this routine frees it for you.
dl | (I/O) Initial date list - gets freed | |
numItems | (I) Number of dates to add | |
array | (I) [numItems] Dates to be added |
TDateList* JpmcdsDateListMakeRegular | ( | TDate | startDate, | |
TDate | endDate, | |||
TDateInterval * | interval, | |||
TStubMethod * | stubType | |||
) |
Makes a date list from a given start date to a given end date with dates seperated by a given interval
Use the stub parameter to determine whether the stub appears at the start or the end of the date list, and whether the stub is long or short.
The start date and end date are always both in the date list. The end date must be strictly after the start date. The date interval must be positive.
startDate | (I) Start date | |
endDate | (I) End date | |
interval | (I) Date interval | |
stubType | (I) Stub type |
TDateList* JpmcdsDateListTruncate | ( | TDateList * | dateList, | |
TDate | truncationDate, | |||
TBoolean | inclusive, | |||
TBoolean | excludeBefore, | |||
TBoolean | inPlace | |||
) |
Truncates a date list at the specified date.
The resulting date list will contain all dates previous to (or following) the specified date. Dates in the datelist which match the specified date may be optionally included.
The datelist may optionally be modified in place or a new copy is returned.
The input date list must be sorted.
dateList | (I/O) Date list to be modified in place | |
truncationDate | (I) Date on which to perform trunctation | |
inclusive | (I) TRUE=include truncation date if in list | |
excludeBefore | (I) TRUE=exclude dates before truncation date | |
inPlace | (I) TRUE=modify date list in place |