Przejdź do treści

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.

func int List_Create(var int data)
Parameters
  • 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.

func void List_Add(var int list, var int data)
Parameters
  • 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.

func void List_AddFront(var int list, var int data)
Parameters
  • 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.

func void List_AddOffset(var int list, var int offset, var int data)
Parameters
  • 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.

func void List_Set(var int node, var int data)
Parameters
  • 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.

func int List_Get(var int list, var int nr)
Parameters
  • 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.

func int List_Node(var int list, var int nr)
Parameters
  • 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).

func int List_Length(var int list)
Parameters
  • 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.

func int List_HasLength(var int list, var int length)
Parameters
  • 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.

func int List_End(var int list)
Parameters
  • 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.

func void List_Concat(var int list, var int list2)
Parameters
  • 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.

func int List_Contains(var int list, var int data)
Parameters
  • 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.

func void List_For(var int list, var string function)
Parameters
  • 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.

func void ListForF(var int list, var func function)
Parameters
  • 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.

func void List_ForI(var int list, var int funcID)
Parameters
  • 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.

func void List_Delete(var int list, var int nr)
Parameters
  • 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.

func void List_Destroy(var int list)
Parameters
  • 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.

func int List_ToArray(var int list)
Parameters
  • 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.

func void List_MoveDown(var int list, var int node)
Parameters
  • 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.

func void List_MoveUp(var int list, var int node)
Parameters
  • 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.

func void List_InsertSorted(var int list, var int data, var func compare)
Parameters:
  • 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

func int List_Compare(var int data1, var int data2, var func compare)
Parameters:
  • 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.

func int List_CmpAscending(var int data1, var int data2)
Parameters:
  • 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.

func int List_CmpDescending(var int data1, var int data2)
Parameters:
  • 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.

func int List_CmpAscendingUnsigned(var int data1, var int data2)
Parameters:
  • 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.

func int List_CmpDescendingUnsigned(var int data1, var int data2)
Parameters:
  • 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.