VECTOR__DEFINE Purpose
These routines define a vector data type. This vector class differs
from an array in that it grows as necessary to accomodate new
data. This enhancement comes at some expense of convenience:
-- The vector carries the baggage associated with objects (they
must be created with obj_new, and destroyed with obj_destroy)
-- Manipulating the data inside a vector is more cumbersome (it
must be done through the vector methods, instead of simple
syntax like array[3:5] = 10. Adding data is also less flexible;
data must be added in contiguous chunks (as opposed to
operations like array[[1,2,5,7]] = [9,8,7,6]
This vector class is distinct from the stack class, in that data
can be accessed and modified anywhere in a vector. In a stack,
objects can only be added to and retrieved from the top of the stack.
Category
Data Types
Calling Sequence
newVector = obj_new('vector') Class Structure
class = {vector,
data : ptr_new() ;- pointer to the vector data
top : 0L ;- the highest occupied index in data
Modification History
May 2009: Written by Chris Beaumont