Quellcode durchsuchen

Update docs

Include updated usage on list functions.
master
TheoryOfNekomata vor 2 Jahren
Ursprung
Commit
7765b46941
1 geänderte Dateien mit 7 neuen und 7 gelöschten Zeilen
  1. +7
    -7
      src/packages/game/data/README.md

+ 7
- 7
src/packages/game/data/README.md Datei anzeigen

@@ -4,7 +4,7 @@ Fundamental functions for various data structures used in the project.


## `list` ## `list`


A singly-linked list is used on certain parts of the game, such as the memory pool's entries of currently allocated game A doubly-linked list is used on certain parts of the game, such as the memory pool's entries of currently allocated game
objects. objects.


Here is how to properly use a list: Here is how to properly use a list:
@@ -26,22 +26,22 @@ int main() {
// lists should accept any type of value (void*), so the implementor is free to use whatever type they want // lists should accept any type of value (void*), so the implementor is free to use whatever type they want
int node1_value = 1; int node1_value = 1;
IZ_ListAppendNode(&list, &node1_value); IZ_ListAppendNode(&list, &node1_value, NULL);
int node2_value = 2; int node2_value = 2;
IZ_ListAppendNode(&list, &node2_value); IZ_ListAppendNode(&list, &node2_value, NULL);
// pass predicate functions for finding nodes // pass predicate functions for finding nodes
ListNode* find_node; ListNode* find_node = NULL;
find_node = IZ_ListFindFirstNode(&list, &FindNodeWithValueTwo); IZ_ListFindFirstNode(&list, &FindNodeWithValueTwo, &find_node);
if (find_node != NULL) { if (find_node != NULL) {
printf("Found node with value 2!\n"); printf("Found node with value 2!\n");
} }
ListNode* delete_node; ListNode* delete_node;
delete_node = IZ_ListFindFirstNode(&list, &FindNodeWithValueOne); IZ_ListFindFirstNode(&list, &FindNodeWithValueOne, &delete_node);
// deletions are done only on one node at a time // deletions are done only on one node at a time
IZ_ListDeleteNode(&list, delete_node); IZ_ListDeleteNode(delete_node);
// teardown takes care of de-allocating nodes and making sure data cannot be accessed sensibly anymore. // teardown takes care of de-allocating nodes and making sure data cannot be accessed sensibly anymore.
IZ_ListTeardown(&list); IZ_ListTeardown(&list);


||||||
x
 
000:0
Laden…
Abbrechen
Speichern