This implementation of linked lists is based on doubly linked lists. So it's possible to jump to next and previous elements.
Features:
* Kinda seamlessly embedding in terms of AppGameKit Basic
* Very comfortable in use
* Supports primitive data-types as well as a key/value concept (KV)
* High performance
* Highly flexible
* Possibility to set/get values in a hard way (performance) as well as in a soft way (flexibility)
* Built-In sorting
* Multi-Level sorting
Note: This is the first version of this lib and so it might still have some bugs - so please keep this in mind. However, if you encounter any bugs please let me know and I will happily fix them. Same is true for any ideas in terms of making this lib better or bigger. However, to keep this thread small in size please use the original thread instead: http://forum.thegamecreators.com/?m=forum_view&t=206778&b=41
Here's a little example program which quickly shows the use of some of "LinkedList.agc"'s functions:
#Include "LinkedList.agc"
SetVirtualResolution(800, 600)
SetPrintSize(12)
Sync()
list = NewList()
For i = 1 to 20
AddElement(list)
SetElement(list, Random(1, 20))
Next i
PrintInfo(list)
SortList(list, 1)
PrintInfo(list)
SortList(list, 2)
PrintInfo(list)
ClearList(list)
For i = 1 to 40
AddElement(list)
SetElementKV$(list, "a", "a-" + Str(Random(1, 999999)))
SetElementKV(list, "b", RandomSign(Random(0, 999999)))
SetElementKV$(list, "c", "c-" + Str(Random(1, 999999)))
SetElementKV#(list, "d", ValFloat(Str(RandomSign(Random(0, 999))) + "." + Str(Random(0, 999))))
SetElementKV$(list, "e", "e-" + Str(Random(1, 999999)))
Next i
SortListKV(list, "a,b,c,d,e", 1)
PrintInfo$(list)
SortListKV(list, "a,b,c,d,e", 2)
PrintInfo$(list)
End
Function PrintInfo(list)
count = ListSize(list)
Print("List-ID = " + Str(list))
Print("Listsize = " + Str(count))
PrintC("Content > = ")
ResetList(list)
While (NextElement(list) <> 0)
PrintC(str(GetElement(list)) + " ")
EndWhile
Print("")
PrintC("Content < = ")
ResetList(list)
While (PreviousElement(list) <> 0)
PrintC(str(GetElement(list)) + " ")
EndWhile
Print("")
Sync()
Sleep(5000)
EndFunction
Function PrintInfo$(list)
count = ListSize(list)
Print("List-ID = " + Str(list))
Print("Listsize = " + Str(count))
Print("Content = ")
ResetList(list)
While (NextElement(list) <> 0)
Print(GetElementKV$(list, "a") + "|" + GetElementKV$(list, "b"))
EndWhile
Print("")
Sync()
Sleep(5000)
EndFunction
Please find the library behind the according download button.
If you have any questions don't hesitate to ask.
Have phun using my lib!
Cheers,
chrisu.