Jo Engine  9
Jo Sega Saturn Engine
Data Structures | Typedefs | Functions
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...
 
struct  jo_list_data.coord
 

Typedefs

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

Functions

void jo_list_init (jo_list *const list)
 Init a list. More...
 
jo_nodejo_list_add (jo_list *const list, const jo_list_data data)
 Add an item on the list. More...
 
static __jo_force_inline jo_nodejo_list_add_ptr (jo_list *const list, void *ptr)
 Add a pointer on the list. More...
 
void jo_list_remove (jo_list *const list, const jo_node *const node_to_delete)
 Remove an item on the list. More...
 
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. More...
 
static __jo_force_inline void jo_list_free_and_clear (jo_list *const list)
 Free node pointers and remove all item. More...
 
static __jo_force_inline void jo_list_free_and_remove_last (jo_list *const list)
 Free and remove the last item from the list. More...
 
static __jo_force_inline void jo_list_remove_last (jo_list *const list)
 Free and remove the last item from the list. More...
 
static __jo_force_inline void jo_list_free_and_remove_first (jo_list *const list)
 Free and remove the first item from the list. More...
 
static __jo_force_inline void jo_list_remove_first (jo_list *const list)
 Free and remove the first item from the list. More...
 
static __jo_force_inline void jo_list_clear (jo_list *const list)
 Remove all item. More...
 
static __jo_force_inline jo_nodejo_list_first (jo_list *const list)
 Get first item. More...
 
static __jo_force_inline jo_nodejo_list_last (jo_list *const list)
 Get last item. More...
 
static __jo_force_inline void jo_list_foreach (jo_list *const list, jo_node_callback callback)
 Iterate on the list. More...
 
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) More...
 
static __jo_force_inline void jo_list_set_allocation_behaviour (jo_list *const list, jo_malloc_behaviour behaviour)
 Set list memory allocation behaviour. More...
 
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. More...
 
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. More...
 

Detailed Description

Jo Engine Linked list helper.

Author
Johannes Fetz
Bug:
No known bugs.

Data Structure Documentation

union jo_list_data

Node data (4 bytes)

Data Fields
bool booleans[4]
struct jo_list_data coord
int integer
void * ptr
char str[4]
struct __jo_node

Node struct.

Data Fields
jo_list_data data
jo_node * next
jo_node * prev
struct jo_list

List struct.

Data Fields
jo_malloc_behaviour allocation_behaviour
int count
jo_node * first
jo_node * last
struct jo_list_data.coord
Data Fields
short x
short y

Typedef Documentation

typedef struct __jo_node jo_node

Node type.

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

Callback for jo_list_any()

typedef void(* jo_node_callback) (jo_node *node)

Callback for jo_list_foreach()

Function Documentation

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
static __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
static __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
static __jo_force_inline void jo_list_clear ( jo_list *const  list)
static

Remove all item.

Parameters
listList
static __jo_force_inline jo_node* jo_list_first ( jo_list *const  list)
static

Get first item.

Parameters
listList
static __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
static __jo_force_inline void jo_list_free_and_clear ( jo_list *const  list)
static

Free node pointers and remove all item.

Parameters
listList
static __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
static __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
static __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
void jo_list_init ( jo_list *const  list)

Init a list.

Parameters
listList pointer
static __jo_force_inline jo_node* jo_list_last ( jo_list *const  list)
static

Get last item.

Parameters
listList
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
static __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
static __jo_force_inline void jo_list_remove_first ( jo_list *const  list)
static

Free and remove the first item from the list.

Parameters
listList
static __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
static __jo_force_inline void jo_list_remove_last ( jo_list *const  list)
static

Free and remove the last item from the list.

Parameters
listList
static __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