Linked Lists
A linked list allows you to efficiently add and remove objects to a collection of objects.
To create a linked list, use the CreateList command.
You add objects to a linked list using ListAddFirst or ListAddLast. Both commands return a link object which can be used to later remove the added object with the RemoveLink command. You can also remove objects with the ListRemove command. However this is not as efficient as using RemoveLink because the list must first be searched for the object to be removed.
To visit all the objects in a linked list, you can use a For...EachIn loop.
Function reference
CreateList:TList() Create a linked list
ClearList( list:TList ) Clear a linked list
Removes all objects from list.
CountList( list:TList ) Count list length
Returns: The numbers of objects in list.
ListIsEmpty( list:TList ) Check if list is empty
Returns: True if list is empty, else false
ListContains( list:TList,value:Object ) Check if list contains a value
Returns: True if list contains value, else false
SortList( list:TList,ascending=True ) Sort a list
ListFromArray:TList( arr:Object[] ) Create a list from an array
Returns: A new linked list
ListToArray:Object[]( list:TList ) convert a list to an array
Returns: An array of objects
SwapLists( list_x:TList,list_y:TList ) Swap the contents of 2 lists
ReverseList( list:TList ) Reverse the order of elements of a list
ListFindLink:TLink( list:TList,value:Object ) Find a link in a list
Returns: The link containting value
ListAddLast:TLink( list:TList,value:Object ) Add an object to a linked list
ListAddFirst:TLink( list:TList,value:Object ) Add an object to a linked list
ListRemove( list:TList,value:Object ) Remove an object from a linked list
ListRemove scans a list for the specified value and removes its link.
RemoveLink( link:TLink ) Remove an object from a linked list
Module Information
Module | brl.linkedlist |
Version |
1.00 |
Author |
Mark Sibly |
License |
Blitz Shared Source Code |
Copyright |
Blitz Research Ltd |
Modserver |
BRL |