[Quantproject-developers] QuantProject/b1_ADT/Histories History.cs, 1.14, 1.15
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2008-11-09 19:23:05
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Histories In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22539/b1_ADT/Histories Modified Files: History.cs Log Message: Added methods ContainsAllTheDateTimesIn and ContainsAtAGivenPercentageDateTimesIn Index: History.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Histories/History.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** History.cs 29 Sep 2008 21:12:26 -0000 1.14 --- History.cs 9 Nov 2008 19:23:02 -0000 1.15 *************** *** 126,129 **** --- 126,160 ---- } + /// <summary> + /// Returns true iif current history contains all the + /// dateTimes contained in the given comparingHistoryOfDateTimes + /// </summary> + public bool ContainsAllTheDateTimesIn( History comparingHistoryOfDateTimes ) + { + bool returnValue = true; + foreach ( DateTime dateTime in comparingHistoryOfDateTimes.Keys ) + if ( ! this.ContainsKey( dateTime ) ) + returnValue = false; + return returnValue; + } + + /// <summary> + /// Returns true iif current history contains at the given percentage the + /// dateTimes contained in the given comparingHistoryOfDateTimes + /// </summary> + public bool ContainsAtAGivenPercentageDateTimesIn( History comparingHistoryOfDateTimes, double percentageOfDateTimes ) + { + if(percentageOfDateTimes <= 0 || percentageOfDateTimes > 100) + throw new Exception ("invalid percentage"); + int numberOfContainedDateTimes = 0; + int numberOfComparingDateTimes = comparingHistoryOfDateTimes.Count; + foreach ( DateTime dateTime in comparingHistoryOfDateTimes.Keys ) + if ( this.ContainsKey( dateTime ) ) + numberOfContainedDateTimes++; + + return numberOfContainedDateTimes >= + (percentageOfDateTimes * numberOfComparingDateTimes)/100; + } + public void Interpolate( ICollection dateTimeCollection , IInterpolationMethod interpolationMethod ) |