Vector_clear |
Homepage Containers |
Destroys (and removes) each item in the Vector, setting the new size to zero.
Result := Vector_clear(VectorObject)
| VectorObject | The Vector object to use for the current operation. |
If VectorObject is NULL (0 or blank), the empty string is returned, to indicate an error.
Calling this function does not destroy the Vector object - only the data within. To destroy the Vector object, call Vector_destroy instead.
;Creates a new Vector myVector := Vector_new() ;Adds two items to myVector Vector_add(myVector, String_new("Item1")) Vector_add(myVector, String_new("Item2")) ;Outputs the current values MsgBox, % "Before clear:`n" . "Value1: " . Vector_get(myVector, 1) . "`n" . "Value2: " . Vector_get(myVector, 2) ;Clears the Vector Vector_clear(myVector) ;myVector is now empty ;the empty string will be returned for the values, since size = 0 MsgBox, % "After clear:`n" . "Value1: " . Vector_get(myVector, 1) . "`n" . "Value2: " . Vector_get(myVector, 2) ;Outputs the Vector's size (0). ;Note: the Vector still exists, so its address is still valid. MsgBox, % "myVector has " Vector_size(myVector) " elements."