Vector_add

Homepage Containers

Inserts the object at the specified position.

Result := Vector_add(VectorObject, object)
Result := Vector_add(VectorObject, index, object)

Parameters

VectorObject The Vector object to use for the current operation.
index Index at which to insert the new object. If omitted, the object is appended to the end of the Vector.
object The class object to insert at the specified position.

Return Value

True (1) to indicate the object was successfully added.

Remarks

If VectorObject is NULL (0 or blank), the empty string is returned, to indicate an error.

If the new size (after adding the item) is greater than the capacity, the capacity automatically increases to accommodate the new item. The rate at which the capacity increases is based on the Vector's capacity increment. If the system has insufficient memory to increase the capacity (very rare), the old data remains untouched, and the empty string is returned, to indicate the error.

Index values start at 1 and "wrap".

Related

Vector_addAll

Vector

Examples

;Creates a new Vector with the default parameters.
myVector := Vector_new()

;Adds a String object to myVector (appends to the end).
aString := String_new("Hello World!")
Vector_add(myVector, aString)

;Adds a String object to myVector (at index 1).
aString2 := String_new("Item1")
Vector_add(myVector, 1, aString2)

;Outputs the two items, in order.
MsgBox, % "myVector, index 1: " . Vector_get(myVector, 1) . "`n"
        . "myVector, index2 : " . Vector_get(myVector, 2)

Homepage  |  Containers