Anyone have any examples using FindLink?

BlitzMax Forums/BlitzMax Programming/Anyone have any examples using FindLink?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Example of using FindLink
Local list:Tlist = CreateList()

Type mytype
	Field id
	Method New()
		id = Rand(0,255)
	End Method
End Type

Local m1:mytype = New mytype; list.AddLast(m1)
Local m2:mytype = New mytype; list.AddLast(m2)
Local m3:mytype = New mytype; list.AddLast(m3)
Local m4:mytype = New mytype; list.AddLast(m4)
Local m5:mytype = New mytype; list.AddLast(m5)
Local m6:mytype = Null
Local mlink:TLink 

mlink = list.FindLink(m2)
If mlink Notify mytype(mlink.Value()).id
	
mlink = list.FindLink(m6)
If mlink Notify mytype(mlink.Value()).id


Example of using ValueAtIndex
Local list:Tlist = CreateList()

Type mytype
	Field id
	Method New()
		id = Rand(0,255)
	End Method
End Type

Local m1:mytype = New mytype; list.AddLast(m1)
Local m2:mytype = New mytype; list.AddLast(m2)
Local m3:mytype = New mytype; list.AddLast(m3)
Local m4:mytype = New mytype; list.AddLast(m4)
Local m5:mytype = New mytype; list.AddLast(m5)
Local m:mytype

m = mytype(list.ValueAtIndex(0))
If m Notify m.id
	
m = mytype(list.ValueAtIndex(3))
If m Notify m.id


Example of using Compare
Local list:Tlist = CreateList()

Type mytype
	Field id
	Method New()
		id = Rand(0,255)
	End Method
	
	Method Compare(other:Object)
		Return id-mytype(other).id
	End Method
End Type

Local m1:mytype = New mytype; list.AddLast(m1)
Local m2:mytype = New mytype; list.AddLast(m2)
Local m3:mytype = New mytype; list.AddLast(m3)
Local m4:mytype = New mytype; list.AddLast(m4)
Local m5:mytype = New mytype; list.AddLast(m5)
Local m:mytype

list.Sort()
For m = EachIn list
	Notify m.id
Next