Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

OHISTORY.H Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

OHISTORY.H

Go to the documentation of this file.
00001 //Filename              : OHistory.h
00002 //Description   : Constants for Finance Class Declaration;
00003 //                                              For inflation rate, interest rate, etc, in HE.response_func->Time_Variation
00004 //Ower             : Fred
00005 
00006 #ifndef __OHISTORY_H
00007 #define __OHISTORY_H
00008 
00009 enum {
00010     FA_HISTORY_YEAR = 12,
00011     //FA_THIS_MONTH = FA_HISTORY_YEAR-1,
00012 };
00013 
00016 struct HistoryData {
00017     // init(char type=FA_HISTORY_YEAR);
00018     int   length;
00019     float   data[FA_HISTORY_YEAR];                  //temp
00020 
00021     HistoryData() {
00022         memset(this, 0, sizeof(HistoryData));
00023         length = FA_HISTORY_YEAR;
00024     }
00025 
00026     void    init(int len) {
00027         memset(this, 0, sizeof(HistoryData));
00028         length = FA_HISTORY_YEAR;
00029     };
00030 
00031     void    init(int len, float value) {
00032         init(len);
00033         for ( int h=0; h<length; h++)
00034             data[h] = value;
00035     };
00036 
00037     void    set_cur(float value)        { data[length-1] = value; };
00038 
00039     float   get_cur()             { return data[length-1]; };
00040     float   oldest_value()            { return data[0]; };
00041 
00042     float   get(int relativeIndex) {                // 0: latest/current data
00043         return data[length-1+relativeIndex];
00044     };
00045 
00046     void    shift_hist() {
00047         for ( int h=0; h<length-1; h++) {
00048             data[h] = data[h+1];
00049         }
00050         data[length-1] = 0;
00051     };
00052 
00053     float   get_sum() {
00054         float sum;  int h;
00055         for ( sum=0, h=0; h<length; h++) {
00056             sum += data[h];
00057         }
00058         return sum;
00059     }
00060 };
00061 #endif

Generated on Fri Aug 23 01:37:58 2002 for VirtualU by doxygen1.2.17