Can't Delete Type?
BlitzMax Forums/BlitzMax Programming/Can't Delete Type?
| ||
Local list_node:TList=New TList Local nodes:Node nodes = New Node list_node.AddFirst nodes For n:Node = EachIn list_node Delete n Next Type Node Field data1:Int,data2:Int,data3:Int End Type |
| ||
Blitzmax uses garbage collection, so all you need to do to delete an object is to remove all references pointing to it. To remove an object from a linked list use RemoveLink. - From the docs regarding the Delete method - New and Delete User defined types can optionally declare two special methods named New and Delete. Both methods must take no arguments, and any returned value is ignored. The New method is called when an object is first created with the New operator. This allows you to perform extra initialization code. The Delete method is called when an object is discarded by the memory manager. Note that critical shutdown operations such as closing files etc should not be placed in the Delete, as you can't always be sure when Delete will be called. |
| ||
like this? For n:Node = EachIn list_node list_node.RemoveFirst Next |
| ||
If you want to clear list then it's faster to use: list_node.Clear() If your list is created as local variable inside a function perhaps, then all the items are cleared automatically when function has ended (object goes out of scope). -Henri |