linked list question

BlitzMax Forums/BlitzMax Beginners Area/linked list question

One option is to convert the list to an array -- not for speed critical stuff, though, so probably no use here!

' A generic Object array to hold a converted list of objects...

Local RocketArray:Object[]

' Example type...

Type Rocket
	Field x
End Type

' List for Rockets...

RocketList:TList = New TList

' Create some rockets and add to list...

For a = 0 To 4
	r:Rocket = New Rocket
	r.x = a
	ListAddLast RocketList, r
Next

' Copy list into RocketArray...

RocketArray = ListToArray (RocketList)

' Show result...

Print ""
Print "Fourth item in list..."
Print ""

' 3 is fourth item: 0, 1, 2, [3], 4

Print Rocket (RocketArray[3]).x