Vector_discard

Homepage Containers

Removes (without destroying) the element stored at the specific position.

ClassObject := Vector_discard(VectorObject, index)

Parameters

VectorObject The Vector object to use for the current operation.
index Index of element to discard.

Return Value

Address for the previous object (see examples for possible uses)

If there is no object set at the specified position, 0 is returned.

Remarks

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

When discarding an object, the previous one is not destroyed (its lock count is still decreased to reflect the removal). Call Vector_remove, instead, if you wish to destroy the previous object.

Index values start at 1 and "wrap".

Related

Vector_get, Vector_getAddress

Vector_set, Vector_replace, Vector_remove

Vector

Examples

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

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

;Removes the last object (without destroying it).
oldObject := Vector_discard(myVector, 0)

;Since the removed object wasn't destroyed, its address is still valid.
MsgBox, % "The old String object: " String_getValue(oldObject)

Homepage  |  Containers