Add support for tree structures. Search function with DFS, BFS currently unimplemented. Improve linked list handling; fix bug in circular list detection.

This commit is contained in:
2026-06-02 12:42:21 -04:00
parent 06b2c8ad8a
commit e4597aef7d
5 changed files with 3080 additions and 1 deletions

33
tests/test_linkedlist.c Normal file
View File

@@ -0,0 +1,33 @@
#include <akstdlib.h>
akerr_ErrorContext AKERR_NOIGNORE *myiter(aksl_ListNode *node, void *data)
{
PREPARE_ERROR(e);
int count;
FAIL_ZERO_RETURN(e, node, AKERR_NULLPOINTER, "node");
FAIL_ZERO_RETURN(e, node->data, AKERR_NULLPOINTER, "node->data");
// This function doesn't use *data so we don't check it
PASS(e, aksl_fprintf(&count, stderr, "Visiting node : %s", node->data));
SUCCEED_RETURN(e);
}
int main(void)
{
PREPARE_ERROR(e);
aksl_ListNode mylist;
char *node1str = "Node 1";
aksl_ListNode node1;
char *node2str = "Node 2";
aksl_ListNode node2;
node1->data = (void *)&node1str;
PASS(e, aksl_list_push(&mylist, &node1));
node2->data = (void *)&node2str;
PASS(e, aksl_list_push(&mylist, &node2));
PASS(e, aksl_list_iterate(&mylist, &myiter, NULL));
SUCCEED_RETURN(e);
}