Jo Engine  2020.06.22
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_insert_at (jo_list *const list, const jo_list_data data, const int index)
 Insert an item on the list at specific index. 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 jo_nodejo_list_at (jo_list *const list, int index)
 Get node at index. More...
 
static __jo_force_inline void jo_list_remove_at (jo_list *const list, const int index)
 Remove an item on the list from index. 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...
 
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. More...
 

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
struct jo_list_data 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

◆ jo_list_data.coord

struct jo_list_data.coord
Data Fields
short x
short y

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()

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

◆ jo_list_any()

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

◆ jo_list_append()

static __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()

static __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()

static __jo_force_inline void jo_list_clear ( jo_list *const  list)
static

Remove all item.

Parameters
listList

◆ jo_list_first()

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

Get first item.

Parameters
listList

◆ jo_list_foreach()

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

◆ jo_list_free_and_clear()

static __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()

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

◆ jo_list_free_and_remove_first()

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

◆ jo_list_free_and_remove_last()

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

◆ 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()

static __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()

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

◆ jo_list_remove_at()

static __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()

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

◆ jo_list_remove_first_value()

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

◆ jo_list_remove_last()

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

◆ jo_list_set_allocation_behaviour()

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