LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
lg_linked_list.c File Reference

Functions

LG_LinkedListlg_list_new (void *data, size_t size)
 
LG_LinkedListlg_list_add (LG_LinkedList *some_node, void *data, size_t size)
 
LG_LinkedListlg_list_remove (LG_LinkedList *node)
 
void lg_list_free (LG_LinkedList *node)
 
void lg_list_free_all (LG_LinkedList *some_node)
 
LG_LinkedListlg_list_first (LG_LinkedList *node)
 
LG_LinkedListlg_list_last (LG_LinkedList *node)
 
LG_LinkedListlg_list_prev (LG_LinkedList *node)
 
LG_LinkedListlg_list_next (LG_LinkedList *node)
 
LG_LinkedListlg_list_nth (LG_LinkedList *some_node, int n)
 
int lg_list_index (LG_LinkedList *some_node)
 
int lg_list_count (LG_LinkedList *some_node)
 

Detailed Description

=== Generic doubly-linked list implementation ===

TODO: unused so far, is this thing too generic ? even useful ?

  • See: lg_textures.c/h
  • Add: lg_list_find_by_STH(LG_LinkedList *some_node, some_type STH)
  • Can be used as a template for a more defined list

Function Documentation

◆ lg_list_new()

LG_LinkedList* lg_list_new ( void *  data,
size_t  size 
)

Bla bla (self-explanatory)

◆ lg_list_add()

LG_LinkedList* lg_list_add ( LG_LinkedList some_node,
void *  data,
size_t  size 
)

Create and add node at end of list 'some_node' may be any node in the list or NULL -> when creating list

◆ lg_list_remove()

LG_LinkedList* lg_list_remove ( LG_LinkedList node)

Bla bla (self-explanatory)

◆ lg_list_free()

void lg_list_free ( LG_LinkedList node)

Free allocated memory and node

◆ lg_list_free_all()

void lg_list_free_all ( LG_LinkedList some_node)

Bla bla (self-explanatory)

◆ lg_list_first()

LG_LinkedList* lg_list_first ( LG_LinkedList node)

Bla bla (self-explanatory)

◆ lg_list_last()

LG_LinkedList* lg_list_last ( LG_LinkedList node)

Bla bla (self-explanatory)

◆ lg_list_prev()

LG_LinkedList* lg_list_prev ( LG_LinkedList node)

Return NULL if no previous node

◆ lg_list_next()

LG_LinkedList* lg_list_next ( LG_LinkedList node)

Return NULL if no next node

◆ lg_list_nth()

LG_LinkedList* lg_list_nth ( LG_LinkedList some_node,
int  n 
)

Return NULL if out of range

◆ lg_list_index()

int lg_list_index ( LG_LinkedList some_node)

Return index if found (starting at 0) / -1 otherwise

◆ lg_list_count()

int lg_list_count ( LG_LinkedList some_node)

Bla bla (self-explanatory)