Notifications
Clear all
[Closed] Dynamic Array Manipulation
Dec 14, 2006 8:32 pm
I’ve declared my array, example: global vArray = #()
So now I can append to my array, but how can I delete a value? Kill, Free, etc.
Thanks!
4 Replies
Dec 14, 2006 8:32 pm
Hi,
You can use a combination of findItem and deleteItem methods like this :
exampleArray = #(4,2,8,3)
print "Before delete:"
print exampleArray
-- Search for item index in array
itemIdx = findItem exampleArray 8
-- If the index returned is not zero
-- The value was found
if itemIdx != 0 then
(
deleteItem exampleArray itemIdx
)
print "After delete:"
print exampleArray
findItem method works also with strings, Point3s, floats etc.
Dec 14, 2006 8:32 pm
Ok, thanks for that…
This findItem method is the most efficient algorythm?
Thanks!
Dec 14, 2006 8:32 pm
This findItem method is the most efficient algorythm?
Yes it is. findItem performs a simple “==” comparison.