List
Info
Dependencies:
- None
Implementation:
List.d on GitHub
The List package is a collection of functions designed to simplify the handling of zCList
and zCListSort
lists in daedalus. It offers a range of functions for creating, manipulating, and querying lists.
Initialization
N/A
Functions
Note
All functions, expect List_Compare
come with an additional "S" at the end for objects of type zCListSort
. (Example: List_NodeS
.) Unlike most LeGo packages, pointers are used here, not handles!
List_Create
List_Create
Creates a list with an initial value.
var int data
The value of the first list element.
Return value
The function returns a pointer to the created list.
List_Add
List_Add
Appends a value to the end of the list.
var int list
The list to be used.var int data
The value to be appended.
List_AddFront
List_AddFront
Adds a value before the first element of the list.
var int list
The list to be used.var int data
The value to be appended.
List_AddOffset
List_AddOffset
Inserts a value between two list elements.
var int list
The list to be used.var int offset
The number of the list element after which the value is inserted.var int data
The value to be appended.
List_Set
List_Set
Sets a list element to a specific value.
var int node
Pointer to a list element.var int data
The value to be written into the list element.
List_Get
List_Get
Retrieves the value of a list element.
var int list
The list to be used.var int nr
The number of the list element.
Return value
The function returns the value of the specified list element.
List_Node
List_Node
Returns a pointer to a list element.
var int list
The list to be used.var int nr
The number of a list element.
Return value
The function returns a pointer to the specified list element.
List_Length
List_Length
Returns the length of the list (number of all elements).
var int list
The list to be used.
Return value
The function returns the number of elements in the list.
List_HasLength
List_HasLength
Checks if the list has the specified length.
var int list
The list to be used.var int length
The desired length.
Return value
The function returns a boolean value indicating whether the list has the specified length or not.
List_End
List_End
Returns the last list element of the list.
var int list
The list to be used.
Return value
The function returns a pointer to the last list element.
List_Concat
List_Concat
Concatenates two lists.
var int list
The first list.var int list2
The second list. Its beginning is appended to the end of the first list.
List_Contains
List_Contains
Returns the last list element with a specific value.
var int list
The list to be used.var int data
The value to search for.
Return value
The function returns the number of the last list element with the value data
.
List_For
List_For
Calls a function for each list element, passing a pointer to the list element as a parameter.
var int list
The list to be used.var string function
Name of a function to be called for each list element (void handler(var int node)
).
List_ForF
List_ForF
Similar to List_For
, but with a function parameter instead of a string.
var int list
The list to be used.var func function
The function to be called for each list element (void handler(var int node)
).
List_ForI
List_ForI
Similar to List_For
, but with a function parameter instead of a string.
var int list
The list to be used.var int funcID
ID of a function to be called for each list element (void handler(var int node)
).
List_Delete
List_Delete
Deletes a list element. All subsequent elements shift position.
var int list
The list to be used.var int nr
The number of the list element to be deleted.
List_Destroy
List_Destroy
Destroys the entire list.
var int list
The list to be destroyed.
List_ToArray
List_ToArray
Returns a pointer to a memory area containing all values of the list.
var int list
The list to be used.
Return value
The function returns a memory area containing all the values of the list.
List_MoveDown
List_MoveDown
Moves the specified list node down by one position in the list.
var int list
The list in which the node is located.var int node
The node to be moved down.
List_MoveUp
List_MoveUp
Moves the specified list node up by one position in the list.
var int list
The list in which the node is located.var int node
The node to be moved up.
List_InsertSorted
List_InsertSorted
Inserts a value into a sorted list while preserving the sort order.
var int list
The list to insert the value into.var int data
The value to be inserted.var func compare
A comparison function used to determine the sort order.
List_Compare
List_Compare
var int data1
The first integer value.var int data2
The second integer value.var func compare
One of comparison functions. Return value
The function returns the return value of specified comparison function.
Comparison Functions
The following comparison functions can be used as the compare
parameter in the List_InsertSorted
and List_Compare
function:
List_CmpAscending
List_CmpAscending
Compares two integer values in ascending order.
var int data1
The first integer value.var int data2
The second integer value.
Return Value:
The function returns TRUE
if data1
is greater than data2
, FALSE
is returned otherwise.
List_CmpDescending
List_CmpDescending
Compares two integer values in descending order.
var int data1
The first integer value.var int data2
The second integer value.
Return Value:
The function returns TRUE
if data1
is less than data2
, FALSE
is returned otherwise.
List_CmpAscendingUnsigned
List_CmpAscendingUnsigned
Compares two unsigned integer values in ascending order.
var int data1
The first unsigned integer value.var int data2
The second unsigned integer value.
Return Value:
The function returns TRUE
if data1
is greater than data2
, FALSE
is returned otherwise.
List_CmpDescendingUnsigned
List_CmpDescendingUnsigned
Compares two unsigned integer values in descending order.
var int data1
The first unsigned integer value.var int data2
The second unsigned integer value.
Return Value:
The function returns TRUE
if data1
is less than data2
, FALSE
is returned otherwise.