Vector_discard |
Homepage Containers |
Removes (without destroying) the element stored at the specific position.
ClassObject := Vector_discard(VectorObject, index)
| VectorObject | The Vector object to use for the current operation. |
| index | Index of element to discard. |
If there is no object set at the specified position, 0 is returned.
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".
Vector_set, Vector_replace, Vector_remove
;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)