Vector
A vector is an ordered, indexed collection of objects. Operations get and
set elements by index. The container add function always adds to the end
of the vector; remove leaves a hole.
Implementations:
-
Vector_Growing
Stores a growable vector of objects, growing it when indices go off
the end. Only works for pointer types. Optional constructor args: init
size and growth factor.
-
Vector_TwoVector
Stores at most two elements. Only works for pointer types.
-
Vector_ThreeVector
Stores at most three elements. Only works for pointer types.
Member functions:
-
index : Vector . T -> int
Returns the location of the element in the vector; -1 if not a member.
-
nth: Vector . int -> T
Returns the element at the index.
-
set_nth: Vector . int . T -> void
Sets the element at the index.