MGH_VECTOR__DEFINE Class Name
MGH_Vector Purpose
This class implements a random-access container for heterogeneous
data. It is implemented using an array of pointers.
Properties
COUNT (Get):
The number of items currently stored in the vector.
SIZE (Init, Get, Set):
The capacity of the vector, i.e. the size of the pointer array
used to keep track of the items. The size can be changed via the
SetProperty method. If it is increased then the array is padded
with blank pointers; if it is reduced then any items beyond the
new size are deleted and their pointers freed.
Methods
In addition to the usual suspects (Init, Cleanup, GetProperty,
SetProperty):
Add (Procedure):
This method adds a single item at the end of the vector and
increments the COUNT property. If this would exceed the
capacity of the vector, then the SIZE is increased; the
increase is always done in reasonably large chunks to avoid
performance degradation.
Count (Function):
This method takes no arguments and returns the COUNT property.
Get (Function):
This method retrieves a single item from a position specified
by the POSITION keyword. The default is POSITION=0. The item
is not removed from the vector. (There is no way of removing
items other than by reducing the SIZE).
Put (Procedure):
This method puts a new value into a position specified by the
POSITION keyword (default is POSITION=0). There must already
be a value stored at this location.
###########################################################################
This software is provided subject to the following conditions:
1. NIWA makes no representations or warranties regarding the
accuracy of the software, the use to which the software may
be put or the results to be obtained from the use of the
software. Accordingly NIWA accepts no liability for any loss
or damage (whether direct of indirect) incurred by any person
through the use of or reliance on the software.
2. NIWA is to be acknowledged as the original author of the
software where the software is used or presented in any form.
###########################################################################
Modification History
Mark Hadfield, 1999-10:
Written.
Mark Hadfield, 2000-11:
Added the Array method, which returns an array holding the
data.