About Monkey 2 › Forums › Monkey 2 Programming Help › Passing a Struct type that's within a class
This topic contains 2 replies, has 2 voices, and was last updated by 
 peterigz
 2 years, 10 months ago.
- 
		AuthorPosts
 - 
		
			
				
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:
[/crayon]Monkey123456[crayon-5cba1498e3e80820695952 inline="true" ] Method RemoveRect(r:tlBox)'remove a boudning box from the nodeobjects.Remove(r)numberofobjects-=1r.quad = NullEndNow 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:
[/crayon]Monkey123456[crayon-5cba1498e3e85730637297 inline="true" ] Method RemoveRect(r:tlBox, i:List.Iterator)'remove a boudning box from the nodei.Erase()numberofobjects-=1r.quad = NullEndI’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 #1038Not 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 #1042I 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
–
[/crayon]Monkey12345678910111213141516171819202122232425[crayon-5cba1498ea48b872017276 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()WendEndBefore I was just using List.Iterator without specifying the <generic> bit.
 - 
		AuthorPosts
 
You must be logged in to reply to this topic.