June 11, 2016 at 4:00 pm #1035
I was just trying to modify the way I remove things from a list due to the “Concurrent list modification” error you get now which is fine. What I had was a method that removed the item like this:Monkey123456[crayon-5cbbb86d6c01d642119835 inline="true" ] Method RemoveRect(r:tlBox)'remove a boudning box from the nodeobjects.Remove(r)numberofobjects-=1r.quad = NullEnd
Now I’d like to remove using the “Erase” method in the Iterator Struct but how do I pass that “type” to that method? Along the lines of:Monkey123456[crayon-5cbbb86d6c023925545176 inline="true" ] Method RemoveRect(r:tlBox, i:List.Iterator)'remove a boudning box from the nodei.Erase()numberofobjects-=1r.quad = NullEnd
I’m actually going to redo it so I don’t need to pass in the iterator anyway but I’m still curious either way, is it possible?June 11, 2016 at 7:13 pm #1038
Not 100% sure what you mean here, but the general idea of the iterator ‘Erase’ method is that the iterator already points to the thing you want to erase, so the second RemoveRect doesn’t make sense to me: if ‘i’ doesn’t point to the ‘r’ you want to erase, you’ll need to find it first so ‘i’ is redundant. If ‘i’ does point to the ‘r’ you want to erase, then the ‘r’ is redundant!June 11, 2016 at 10:03 pm #1042
I was just curious about how you actually pass an iterator to a function. Or how do you pass a “type” that is a sub type (if that’s what it’s called) of a class. And in preparing an example I’ve actually found out how 🙂 –Monkey12345678910111213141516171819202122232425[crayon-5cbbb86d73175104503240 inline="true" ]#Import "<std>"Using std..Class tlQuadTreeNodeEndFunction DoSomethingWithIterator(i:List<tlQuadTreeNode>.Iterator)EndFunction Main()Local list:=New List<tlQuadTreeNode>list.AddLast(New tlQuadTreeNode)Local it:=list.All()While not it.AtEndDoSomethingWithIterator(it)it.Bump()WendEnd
Before I was just using List.Iterator without specifying the <generic> bit.
You must be logged in to reply to this topic.