'SortList
'Bmax 1.34 - 05 sept 2009
SuperStrict
Type usertype
Global list:TList=New TList
Field name:String
Field value:Int
Field link:TLink 'a direct link to the list
Function Create:usertype(_na$="",_val:Int=0)
Local temp:usertype=New usertype
temp.name=_na
temp.value=_val
'the usertype object is stored in the list
'and we 'remember' its link in a field to
'access it FASTER
temp.link=ListAddLast(list,temp)
Return temp
End Function
End Type
Local jim:usertype=usertype.Create("Jim",25)
Local Tom:usertype=usertype.Create("Tom",55)
Local Bit:usertype=usertype.Create("Bit",5)
'as we know 'where' is in the list an object, we can access directly to it
'via the LINK field
'we can remove it directly
For Local users:usertype=EachIn usertype.list
Print users.name+" "+users.value
Next
bit.link.remove() 'or we could use ListFindLink(usertype.list,bit) - but it's slower...
Print
'now Bit is gone...
For Local users:usertype=EachIn usertype.list
Print users.name+" "+users.value
Next
|