Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
list.h File Reference

Jo Engine Linked list helper. More...

Go to the source code of this file.

Data Structures

union  jo_list_data
 Node data (4 bytes). More...
struct  __jo_node
 Node struct. More...
struct  jo_list
 List struct. More...

Typedefs

typedef struct __jo_node jo_node
 Node type.
typedef void(*) jo_node_callback(jo_node *node)
 Callback for jo_list_foreach().
typedef bool(*) jo_node_any_callback(jo_node *node, void *extra)
 Callback for jo_list_any().

Functions

void jo_list_init (jo_list *const list)
 Init a list.
jo_node * jo_list_insert_at (jo_list *const list, const jo_list_data data, const int index)
 Insert an item on the list at specific index.
jo_node * jo_list_add (jo_list *const list, const jo_list_data data)
 Add an item on the list.
static __jo_force_inline jo_node * jo_list_add_ptr (jo_list *const list, void *ptr)
 Add a pointer on the list.
void jo_list_remove (jo_list *const list, const jo_node *const node_to_delete)
 Remove an item on the list.
static __jo_force_inline jo_node * jo_list_at (jo_list *const list, int index)
 Get node at index.
static __jo_force_inline void jo_list_remove_at (jo_list *const list, const int index)
 Remove an item on the list from index.
static __jo_force_inline void jo_list_free_and_remove (jo_list *const list, const jo_node *const node_to_delete)
 Free node pointer and remove the item from the list.
static __jo_force_inline void jo_list_free_and_clear (jo_list *const list)
 Free node pointers and remove all item.
static __jo_force_inline void jo_list_free_and_remove_last (jo_list *const list)
 Free and remove the last item from the list.
static __jo_force_inline void jo_list_remove_last (jo_list *const list)
 Free and remove the last item from the list.
static __jo_force_inline void jo_list_free_and_remove_first (jo_list *const list)
 Free and remove the first item from the list.
static __jo_force_inline void jo_list_remove_first (jo_list *const list)
 Free and remove the first item from the list.
static __jo_force_inline void jo_list_clear (jo_list *const list)
 Remove all item.
static __jo_force_inline jo_node * jo_list_first (jo_list *const list)
 Get first item.
static __jo_force_inline jo_node * jo_list_last (jo_list *const list)
 Get last item.
static __jo_force_inline void jo_list_foreach (jo_list *const list, jo_node_callback callback)
 Iterate on the list.
static __jo_force_inline bool jo_list_any (jo_list *const list, jo_node_any_callback callback, void *extra)
 Find if any element of the list satisfy the condition (callback).
static __jo_force_inline void jo_list_set_allocation_behaviour (jo_list *const list, jo_malloc_behaviour behaviour)
 Set list memory allocation behaviour.
static __jo_force_inline bool jo_list_remove_first_value (jo_list *const list, jo_list_data data)
 Remove the first item on the list that match DATA.
static __jo_force_inline void jo_list_remove_all_value (jo_list *const list, jo_list_data data)
 Remove all items on the list that match DATA.
static __jo_force_inline void jo_list_append (const jo_list *const list, jo_list *const output)
 Append all items on the list to output list.

Detailed Description

Jo Engine Linked list helper.

Author
Johannes Fetz
Bug
No known bugs.

Data Structure Documentation

◆ jo_list_data

union jo_list_data

Node data (4 bytes).

Data Fields
bool booleans[4]
char c
char * ch_arr
struct coord
int integer
void * ptr
char str[4]
unsigned char uc

◆ __jo_node

struct __jo_node

Node struct.

Data Fields
jo_list_data data
jo_node * next
jo_node * prev

◆ jo_list

struct jo_list

List struct.

Data Fields
jo_malloc_behaviour allocation_behaviour
int count
jo_node * first
jo_node * last

Typedef Documentation

◆ jo_node

typedef struct __jo_node jo_node

Node type.

◆ jo_node_any_callback

typedef bool(*) jo_node_any_callback(jo_node *node, void *extra)

Callback for jo_list_any().

◆ jo_node_callback

typedef void(*) jo_node_callback(jo_node *node)

Callback for jo_list_foreach().

Function Documentation

◆ jo_list_add()

jo_node * jo_list_add ( jo_list *const list,
const jo_list_data data )

Add an item on the list.

Parameters
listList
dataitem to add
Returns
Created node on the list

◆ jo_list_add_ptr()

__jo_force_inline jo_node * jo_list_add_ptr ( jo_list *const list,
void * ptr )
static

Add a pointer on the list.

Parameters
listList
ptrPointer to add <=> jo_list_data:ptr
Returns
Created node on the list

◆ jo_list_any()

__jo_force_inline bool jo_list_any ( jo_list *const list,
jo_node_any_callback callback,
void * extra )
static

Find if any element of the list satisfy the condition (callback).

Parameters
listList
extraExtra data passed to the callback
callbackcallback for each node
Returns
true if any element satisfy the condition otherwise false

◆ jo_list_append()

__jo_force_inline void jo_list_append ( const jo_list *const list,
jo_list *const output )
static

Append all items on the list to output list.

Parameters
listList
outputOutput list

◆ jo_list_at()

__jo_force_inline jo_node * jo_list_at ( jo_list *const list,
int index )
static

Get node at index.

Remarks
Returns first or last node if out of bounds
Parameters
listList
indexNode index

◆ jo_list_clear()

__jo_force_inline void jo_list_clear ( jo_list *const list)
static

Remove all item.

Parameters
listList

◆ jo_list_first()

__jo_force_inline jo_node * jo_list_first ( jo_list *const list)
static

Get first item.

Parameters
listList

◆ jo_list_foreach()

__jo_force_inline void jo_list_foreach ( jo_list *const list,
jo_node_callback callback )
static

Iterate on the list.

Parameters
listList
callbackcallback for each node

◆ jo_list_free_and_clear()

__jo_force_inline void jo_list_free_and_clear ( jo_list *const list)
static

Free node pointers and remove all item.

Parameters
listList

◆ jo_list_free_and_remove()

__jo_force_inline void jo_list_free_and_remove ( jo_list *const list,
const jo_node *const node_to_delete )
static

Free node pointer and remove the item from the list.

Parameters
listList
node_to_deleteNode to remove

◆ jo_list_free_and_remove_first()

__jo_force_inline void jo_list_free_and_remove_first ( jo_list *const list)
static

Free and remove the first item from the list.

Parameters
listList

◆ jo_list_free_and_remove_last()

__jo_force_inline void jo_list_free_and_remove_last ( jo_list *const list)
static

Free and remove the last item from the list.

Parameters
listList

◆ jo_list_init()

void jo_list_init ( jo_list *const list)

Init a list.

Parameters
listList pointer

◆ jo_list_insert_at()

jo_node * jo_list_insert_at ( jo_list *const list,
const jo_list_data data,
const int index )

Insert an item on the list at specific index.

Parameters
listList
dataItem to insert
indexNode index
Returns
Created node on the list

◆ jo_list_last()

__jo_force_inline jo_node * jo_list_last ( jo_list *const list)
static

Get last item.

Parameters
listList

◆ jo_list_remove()

void jo_list_remove ( jo_list *const list,
const jo_node *const node_to_delete )

Remove an item on the list.

Parameters
listList
node_to_deleteNode to remove

◆ jo_list_remove_all_value()

__jo_force_inline void jo_list_remove_all_value ( jo_list *const list,
jo_list_data data )
static

Remove all items on the list that match DATA.

Parameters
listList
dataNode DATA

◆ jo_list_remove_at()

__jo_force_inline void jo_list_remove_at ( jo_list *const list,
const int index )
static

Remove an item on the list from index.

Parameters
listList
indexNode index

◆ jo_list_remove_first()

__jo_force_inline void jo_list_remove_first ( jo_list *const list)
static

Free and remove the first item from the list.

Parameters
listList

◆ jo_list_remove_first_value()

__jo_force_inline bool jo_list_remove_first_value ( jo_list *const list,
jo_list_data data )
static

Remove the first item on the list that match DATA.

Parameters
listList
dataNode DATA

◆ jo_list_remove_last()

__jo_force_inline void jo_list_remove_last ( jo_list *const list)
static

Free and remove the last item from the list.

Parameters
listList

◆ jo_list_set_allocation_behaviour()

__jo_force_inline void jo_list_set_allocation_behaviour ( jo_list *const list,
jo_malloc_behaviour behaviour )
static

Set list memory allocation behaviour.

Parameters
listList pointer
behaviourAllocation behaviour