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
|