liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
singly linked list
Collaboration diagram for singly linked list:

Data Structures

struct  a_slist_node
 instance structure for singly linked list node More...
 
struct  a_slist
 instance structure for singly linked list head More...
 

Macros

#define A_SLIST_NODE   {A_NULL}
 
#define A_SLIST_INIT(list)
 
#define a_slist_(_, x)
 cast a list pointer from another type pointer
 
#define a_slist_entry(ptr, type, member)
 access the struct for this entry
 
#define a_slist_entry_next(ptr, type, member)
 
#define a_slist_foreach(it, ctx)
 iterate over a list
 
#define a_slist_forsafe(it, at, ctx)
 iterate over a list safe against removal of list entry
 

Typedefs

typedef struct a_slist_node a_slist_node
 instance structure for singly linked list node
 
typedef struct a_slist a_slist
 instance structure for singly linked list head
 

Functions

void a_slist_ctor (a_slist *ctx)
 constructor for singly linked list head
 
void a_slist_init (a_slist *ctx)
 initialize for singly linked list head
 
void a_slist_dtor (a_slist *ctx)
 destructor for singly linked list head
 
void a_slist_link (a_slist_node *head, a_slist_node *tail)
 link head node and tail node
 
void a_slist_add (a_slist *ctx, a_slist_node *prev, a_slist_node *node)
 insert a node to a list
 
void a_slist_add_head (a_slist *ctx, a_slist_node *node)
 insert a node to a list head
 
void a_slist_add_tail (a_slist *ctx, a_slist_node *node)
 insert a node to a list tail
 
void a_slist_del (a_slist *ctx, a_slist_node *prev)
 delete a node from a list
 
void a_slist_del_head (a_slist *ctx)
 delete a node from a list head
 
void a_slist_mov (a_slist *ctx, a_slist *to, a_slist_node *at)
 moving a list to another list
 
void a_slist_rot (a_slist *ctx)
 rotate a node in the list
 

Detailed Description

Macro Definition Documentation

◆ a_slist_

#define a_slist_ ( _,
x )
Value:
a_cast_s(a_slist_node _, a_cast_s(void _, x))
instance structure for singly linked list node
Definition slist.h:26

cast a list pointer from another type pointer

Parameters
[in]_additional attributes of specified type
[in]xpoints to singly linked list node
Returns
a pointer to singly linked list node

◆ a_slist_entry

#define a_slist_entry ( ptr,
type,
member )
Value:
a_container_of(ptr, type, member)
#define a_container_of(ptr, type, member)
container of a structure member
Definition a.h:888

access the struct for this entry

Parameters
ptrthe &a_slist_node pointer
typethe type of the struct this is embedded in
memberthe name of the a_slist_node within the struct

◆ a_slist_entry_next

#define a_slist_entry_next ( ptr,
type,
member )
Value:
a_slist_entry((ptr)->next, type, member)
#define a_slist_entry(ptr, type, member)
access the struct for this entry
Definition slist.h:53

◆ a_slist_foreach

#define a_slist_foreach ( it,
ctx )
Value:
for (a_slist_node *it = (ctx)->head.next; it; it = it->next)

iterate over a list

Parameters
itthe &a_slist_node to use as a loop counter
ctxpoints to singly linked list head

◆ a_slist_forsafe

#define a_slist_forsafe ( it,
at,
ctx )
Value:
for (a_slist_node *at = &(ctx)->head, *it = at->next; \
it; at = it ? it : at, it = at->next)

iterate over a list safe against removal of list entry

Parameters
itthe &a_slist_node to use as a loop counter
atanother &a_slist_node to use as temporary storage
ctxpoints to singly linked list head

◆ A_SLIST_INIT

#define A_SLIST_INIT ( list)
Value:
{{A_NULL}, &(list).head}

Function Documentation

◆ a_slist_add()

void a_slist_add ( a_slist * ctx,
a_slist_node * prev,
a_slist_node * node )

insert a node to a list

Parameters
[in,out]ctxpoints to singly linked list head
[in]prevprevious singly linked list node
[in]nodea singly linked list node

◆ a_slist_add_head()

void a_slist_add_head ( a_slist * ctx,
a_slist_node * node )

insert a node to a list head

Parameters
[in,out]ctxpoints to singly linked list head
[in]nodea singly linked list node

◆ a_slist_add_tail()

void a_slist_add_tail ( a_slist * ctx,
a_slist_node * node )

insert a node to a list tail

Parameters
[in,out]ctxpoints to singly linked list head
[in]nodea singly linked list node

◆ a_slist_ctor()

void a_slist_ctor ( a_slist * ctx)

constructor for singly linked list head

Parameters
[in,out]ctxpoints to singly linked list head

◆ a_slist_del()

void a_slist_del ( a_slist * ctx,
a_slist_node * prev )

delete a node from a list

Parameters
[in,out]ctxpoints to singly linked list head
[in]prevprevious singly linked list node

◆ a_slist_del_head()

void a_slist_del_head ( a_slist * ctx)

delete a node from a list head

Parameters
[in,out]ctxpoints to singly linked list head

◆ a_slist_dtor()

void a_slist_dtor ( a_slist * ctx)

destructor for singly linked list head

Parameters
[in,out]ctxpoints to singly linked list head

◆ a_slist_init()

void a_slist_init ( a_slist * ctx)

initialize for singly linked list head

Parameters
[in,out]ctxpoints to singly linked list head

◆ a_slist_link()

void a_slist_link ( a_slist_node * head,
a_slist_node * tail )

link head node and tail node

Parameters
[in,out]headthe head node of a list
[in,out]tailthe tail node of a list

◆ a_slist_mov()

void a_slist_mov ( a_slist * ctx,
a_slist * to,
a_slist_node * at )

moving a list to another list

Parameters
[in]ctxpoints to singly linked list head
[in,out]toanother linked list to be inserted
[in]atthe previous &a_slist_node of the inserted node

◆ a_slist_rot()

void a_slist_rot ( a_slist * ctx)

rotate a node in the list

Parameters
[in,out]ctxpoints to singly linked list head