View Full Version : Dynamic Array Manipulation
Celarien 12-14-2006, 08: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!
|
|
Light
12-14-2006, 08:40 PM
Hi,
Use deleteItem array index
Light
ypuech
12-14-2006, 08:47 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.
Celarien
12-15-2006, 11:19 AM
Ok, thanks for that...
This findItem method is the most efficient algorythm?
Thanks!
ypuech
12-15-2006, 11:26 AM
This findItem method is the most efficient algorythm?
Yes it is. findItem performs a simple "==" comparison.
CGTalk Moderation
12-15-2006, 11:26 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.