Notifications
Clear all

[Closed] Dynamic Array Manipulation

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

Hi,

Use deleteItem array index

Light

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.

Ok, thanks for that…
This findItem method is the most efficient algorythm?

Thanks!

This findItem method is the most efficient algorythm?

Yes it is. findItem performs a simple “==” comparison.