It's probably been asked before but anyway... I'd like to verify the validity of a list element from its pointer, without going into a ForEach loop, for performance reasons.
Code: Select all
NewList lst.i()
AddElement(lst())
lst() = 12
AddElement(lst())
lst() = 15
*a = @lst()
DeleteElement(lst())
ChangeCurrentElement(lst(), *a)
DeleteElement(lst())
Code: Select all
If IsValidElement(lst(), *a)
ChangeCurrentElement(lst(), *a)
DeleteElement(lst())
EndIf
I'd like to avoid putting my pointer at 0 after removing it the first time (and do a If *a = 0 check), because on a big source code, it can be a pain to do that everywhere. My Delete() function should ensure that the thing I want it to delete actually exists.
(too bad ChangeCurrentElement() doesn't return anything)