Sets the maximum number of elements in the history to aSize.
Initial contents of the history is undefined; you may use
the zero() function to set all elements to zero or use
the initialize() function to set all elements to an
arbitrary initial value.
~History();
Deletes the storage space for data.
void fillArray(type* anArray, long numElements,
long youngestIndex = 0) const;
Copies history data into anArray such that
anArray[numElements-1] contains history[youngestIndex]
and anArray[0] contains the oldest history value requested,
history[youngestIndex-numElements-1]. You
must guarentee that the oldest index used in the history is
valid, i.e., youngestIndex-numElements-1 >=
-history.getSize()+1. Also, there must be enough space
already allocated in anArray to store all of the requested
elements. Example: suppose you want the last three values
inserted into the history; then, do:
fillArray(x, 3, 0)
This will set x[0] = history[-2], x[1] = history[-1], and x[2] = history[0].
long getSize(void) const;
Returns the maximum number of elements that can be held in the
history at any time. history[-getSize()+1] is the oldest
possible history element.
void initialize(type aValue);
Set the value of all the elements in the history to aValue .
void insert(type anElement);
Increments the history. Places anElement in history[0], and
the previous history[0] value goes into history[-1],
etc. The old History[-getSize()+1] value is erased.
type& operator[](long anIndex);
Returns a reference to an element in the history. It is up to
the user to guarentee a valid index. Valid indices are in
the range from -getSize()+1 to getSize()-1.
The current inserted history element is in history[0]. The
previous value inserted is in history[-1], etc. If
anIndex is positive, then it will automatically be
multiplied by -1.
void setSize(long aSize);
Sets the maximum number of elements in the history to be aSize.
Must be positive. The old history values are lost. The new
history elements are uninitialized.