C Everything
This is a C repository containing a curated set of generic data structures and algorithm.
link_list.c File Reference

Contains definitions of routines supported by link list. More...

#include "link_list.h"

Go to the source code of this file.

Functions

void add_begin_sll (t_gen d, t_gen data)
 
Add Beggining for singly LL More...
 
void add_begin_dll (t_gen d, t_gen data)
 
Add Beggining for doubly LL More...
 
void add_begin_scll (t_gen d, t_gen data)
 
Add Beggining for Singly Circular LL More...
 
void add_begin_dcll (t_gen d, t_gen data)
 
Add Beggining for Doubly Circular LL More...
 
void add_begin_xor_dll (t_gen d, t_gen data)
 
Add begin in xor link list More...
 
void add_end_sll (t_gen d, t_gen data)
 
Add End for Singly LL More...
 
void add_end_dll (t_gen d, t_gen data)
 
Add End for Doublly LL More...
 
void add_end_scll (t_gen d, t_gen data)
 
Add End for Singly Circular LL More...
 
void add_end_dcll (t_gen d, t_gen data)
 
Add End for Doubly Circular LL More...
 
void add_end_xor_dll (t_gen d, t_gen data)
 
add end in xor link list More...
 
t_gen del_node_sll (t_gen d, t_gen data)
 
Delete node with matching data in singly LL and return the instance More...
 
t_gen del_node_dll (t_gen d, t_gen data)
 
Delete node with matching data in Doublly LL and return the instance More...
 
t_gen del_node_scll (t_gen d, t_gen data)
 
Delete node with matching data in Singly Circular LL and return the instance More...
 
t_gen del_node_dcll (t_gen d, t_gen data)
 
Delete node with matching data in Doubly Circular LL and return the instance More...
 
t_gen del_node_xor_dll (t_gen d, t_gen data)
 
Delete node with matching data in xor link list More...
 
t_gen del_node_sll_idx (t_gen d, int idx)
 
Delete node with matching index in singly LL and return the instance More...
 
t_gen del_node_dll_idx (t_gen d, int idx)
 
Delete node with matching index in Doublly LL and return the instance More...
 
t_gen del_node_scll_idx (t_gen d, int idx)
 
Delete node with matching index in Singly Circular LL and return the instance More...
 
t_gen del_node_dcll_idx (t_gen d, int idx)
 
Delete node with matching index in Doubly Circular LL and return the instance More...
 
t_gen del_node_xor_idx (t_gen d, int idx)
 
Delete node with matching index in XOR LL and return the instance More...
 
int linklist_length (t_gen d)
 
Length of the link list More...
 
t_gen linklist_find (t_gen d, t_gen data)
 Brief description. Find data in the link list. More...
 
t_gen linklist_getnode (t_gen d, int idx)
 Get the i th node of the link list idx of node should be between 0 and < list count. More...
 
void linklist_print (t_gen d)
 
Print the elems of link list More...
 
void linklist_print_info (t_gen d)
 
Print the elem in linklist with linkinfo More...
 
void destroy_link_list (t_gen d)
 
Destroy instance of the LL More...
 
t_gen linklist_get_head (t_gen d)
 
Get the head node of link list More...
 
t_gen linklist_get_tail (t_gen d)
 
Get the tail node of link list More...
 
t_gen linklist_get_end (t_gen d)
 
Get the end of link list More...
 
t_gen linklist_get_next (t_gen d, t_gen n)
 
Get the next node of given node in link list limitation for xor next node be it iterrates from head meaning first call should pass head node addr and next time next node and so on More...
 
t_gen linklist_get_prev (t_gen d, t_gen n)
 
Get the prev node of given node in link list limitation for xor prev node be it iterrates from tail meaning first call should pass tail node addr and next time the node before tail and so on More...
 
t_gen linklist_get_node_data (t_gen n)
 
Fetch node data; More...
 
t_gen xor (t_gen x, t_gen y)
 
Util fuction to complete xor operation between two pointers returns the xor'ed result as a t_gen type More...
 
t_gen create_link_list (char *name, e_lltype type, t_dparams *prm)
 
Create an instance of link list More...
 
char * get_lltype_name (e_lltype type)
 

Variables

f_ins add [] = {add_begin_sll,add_begin_dll,add_begin_scll,add_begin_dcll, add_begin_xor_dll}
 Look Up function ptrs for add based on type of list. More...
 
f_ins append [] = {add_end_sll,add_end_dll,add_end_scll,add_end_dcll, add_end_xor_dll}
 Look Up function ptrs for apend (add end) based on type of list. More...
 
f_del del [] = {del_node_sll, del_node_dll, del_node_scll, del_node_dcll, del_node_xor_dll}
 Look Up function ptrs for delete node based on type of list. More...
 
f_del_idx del_idx [] = {del_node_sll_idx, del_node_dll_idx, del_node_scll_idx, del_node_dcll_idx, del_node_xor_idx}
 Look Up function ptrs for delete ith node based on type of list. More...
 

Detailed Description

Contains definitions of routines supported by link list.

Definition in file link_list.c.

Function Documentation

◆ add_begin_dcll()

void add_begin_dcll ( t_gen  d,
t_gen  data 
)


Add Beggining for Doubly Circular LL

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 211 of file link_list.c.

◆ add_begin_dll()

void add_begin_dll ( t_gen  d,
t_gen  data 
)


Add Beggining for doubly LL

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 149 of file link_list.c.

◆ add_begin_scll()

void add_begin_scll ( t_gen  d,
t_gen  data 
)


Add Beggining for Singly Circular LL

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 181 of file link_list.c.

◆ add_begin_sll()

void add_begin_sll ( t_gen  d,
t_gen  data 
)


Add Beggining for singly LL

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 123 of file link_list.c.

◆ add_begin_xor_dll()

void add_begin_xor_dll ( t_gen  d,
t_gen  data 
)


Add begin in xor link list

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 251 of file link_list.c.

◆ add_end_dcll()

void add_end_dcll ( t_gen  d,
t_gen  data 
)


Add End for Doubly Circular LL

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 370 of file link_list.c.

◆ add_end_dll()

void add_end_dll ( t_gen  d,
t_gen  data 
)


Add End for Doublly LL

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 312 of file link_list.c.

◆ add_end_scll()

void add_end_scll ( t_gen  d,
t_gen  data 
)


Add End for Singly Circular LL

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 341 of file link_list.c.

◆ add_end_sll()

void add_end_sll ( t_gen  d,
t_gen  data 
)


Add End for Singly LL

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 285 of file link_list.c.

◆ add_end_xor_dll()

void add_end_xor_dll ( t_gen  d,
t_gen  data 
)


add end in xor link list

Parameters
d- Pointer to instance of link list
data- Pointer to the data to be added
Returns
- NA

Definition at line 400 of file link_list.c.

◆ create_link_list()

t_gen create_link_list ( char *  name,
e_lltype  type,
t_dparams prm 
)


Create an instance of link list

Parameters
name- Name of link list instance
type- Type of link list to be created
prm- Data type specific parameters
Returns
- Pointer to instance of link list

Definition at line 69 of file link_list.c.

◆ del_node_dcll()

t_gen del_node_dcll ( t_gen  d,
t_gen  data 
)


Delete node with matching data in Doubly Circular LL and return the instance

Parameters
d- Pointer to instance of link list
data- Pointer to the data which has to be deleted
Returns
- Pointer to the data

Definition at line 619 of file link_list.c.

◆ del_node_dcll_idx()

t_gen del_node_dcll_idx ( t_gen  d,
int  idx 
)


Delete node with matching index in Doubly Circular LL and return the instance

Parameters
d- Pointer to instance of link list
idx- index of the node to be deleted
Returns
- Pointer to the data of the deleted node

Definition at line 947 of file link_list.c.

◆ del_node_dll()

t_gen del_node_dll ( t_gen  d,
t_gen  data 
)


Delete node with matching data in Doublly LL and return the instance

Parameters
d- Pointer to instance of link list
data- Pointer to the data which has to be deleted
Returns
- Pointer to the data

Definition at line 491 of file link_list.c.

◆ del_node_dll_idx()

t_gen del_node_dll_idx ( t_gen  d,
int  idx 
)


Delete node with matching index in Doublly LL and return the instance

Parameters
d- Pointer to instance of link list
idx- index of the node to be deleted
Returns
- Pointer to the data of the deleted node

Definition at line 818 of file link_list.c.

◆ del_node_scll()

t_gen del_node_scll ( t_gen  d,
t_gen  data 
)


Delete node with matching data in Singly Circular LL and return the instance

Parameters
d- Pointer to instance of link list
data- Pointer to the data which has to be deleted
Returns
- Pointer to the data

Definition at line 556 of file link_list.c.

◆ del_node_scll_idx()

t_gen del_node_scll_idx ( t_gen  d,
int  idx 
)


Delete node with matching index in Singly Circular LL and return the instance

Parameters
d- Pointer to instance of link list
idx- index of the node to be deleted
Returns
- Pointer to the data of the deleted node

Definition at line 879 of file link_list.c.

◆ del_node_sll()

t_gen del_node_sll ( t_gen  d,
t_gen  data 
)


Delete node with matching data in singly LL and return the instance

Parameters
d- Pointer to instance of link list
data- Pointer to the data which has to be deleted
Returns
- Pointer to the data

Definition at line 433 of file link_list.c.

◆ del_node_sll_idx()

t_gen del_node_sll_idx ( t_gen  d,
int  idx 
)


Delete node with matching index in singly LL and return the instance

Parameters
d- Pointer to instance of link list
idx- index of the node to be deleted
Returns
- Pointer to the data of the deleted node

Definition at line 764 of file link_list.c.

◆ del_node_xor_dll()

t_gen del_node_xor_dll ( t_gen  d,
t_gen  data 
)


Delete node with matching data in xor link list

Parameters
d- Pointer to instance of link list
data- Pointer of data for the node to be deleted
Returns
- Pointer to the data of the deleted node

Definition at line 681 of file link_list.c.

◆ del_node_xor_idx()

t_gen del_node_xor_idx ( t_gen  d,
int  idx 
)


Delete node with matching index in XOR LL and return the instance

Parameters
d- Pointer to instance of link list
idx- index of the node to be deleted
Returns
- Pointer to the data of the deleted node

Definition at line 1019 of file link_list.c.

◆ destroy_link_list()

void destroy_link_list ( t_gen  d)


Destroy instance of the LL

Parameters
d- Pointer to instance of link list
Returns
- NA

Definition at line 1373 of file link_list.c.

◆ get_lltype_name()

char* get_lltype_name ( e_lltype  type)

Definition at line 1282 of file link_list.c.

◆ linklist_find()

t_gen linklist_find ( t_gen  d,
t_gen  data 
)

Brief description. Find data in the link list.

Parameters
d- Pointer to instance of link list
data- Pointer to the data
Returns
- Pointer of the node

Definition at line 1130 of file link_list.c.

◆ linklist_get_end()

t_gen linklist_get_end ( t_gen  d)


Get the end of link list

Parameters
d- Pointer to instance of link list
Returns
- End Node pointer

Definition at line 1185 of file link_list.c.

◆ linklist_get_head()

t_gen linklist_get_head ( t_gen  d)


Get the head node of link list

Parameters
d- Pointer to instance of link list
Returns
- Head Node pointer

Definition at line 1161 of file link_list.c.

◆ linklist_get_next()

t_gen linklist_get_next ( t_gen  d,
t_gen  n 
)


Get the next node of given node in link list limitation for xor next node be it iterrates from head meaning first call should pass head node addr and next time next node and so on

Parameters
d- Pointer to instance of link list
n- Pointer to node whose next node is returned
Returns
- Next Node pointer

Definition at line 1217 of file link_list.c.

◆ linklist_get_node_data()

t_gen linklist_get_node_data ( t_gen  n)


Fetch node data;

Parameters
data- Pointer to the node whose data to fetch
Returns
- Node data

Definition at line 110 of file link_list.c.

◆ linklist_get_prev()

t_gen linklist_get_prev ( t_gen  d,
t_gen  n 
)


Get the prev node of given node in link list limitation for xor prev node be it iterrates from tail meaning first call should pass tail node addr and next time the node before tail and so on

Parameters
d- Pointer to instance of link list
n- Pointer to node whose prev node is returned
Returns
- Prev Node pointer

Definition at line 1246 of file link_list.c.

◆ linklist_get_tail()

t_gen linklist_get_tail ( t_gen  d)


Get the tail node of link list

Parameters
d- Pointer to instance of link list
Returns
- Tail Node pointer

Definition at line 1173 of file link_list.c.

◆ linklist_getnode()

t_gen linklist_getnode ( t_gen  d,
int  idx 
)

Get the i th node of the link list idx of node should be between 0 and < list count.

Parameters
d- Pointer to instance of link list
idx- idx, (0 <= idx < list count)
Returns
- Pointer to node

Definition at line 1105 of file link_list.c.

◆ linklist_length()

int linklist_length ( t_gen  d)


Length of the link list

Parameters
d- Pointer to instance of link list
Returns
- length of link list

Definition at line 1091 of file link_list.c.

◆ linklist_print()

void linklist_print ( t_gen  d)


Print the elems of link list

Parameters
d- Pointer to instance of link list
Returns
- NA

Definition at line 1305 of file link_list.c.

◆ linklist_print_info()

void linklist_print_info ( t_gen  d)


Print the elem in linklist with linkinfo

Parameters
d- Pointer to instance of link list
Returns
- NA

Definition at line 1338 of file link_list.c.

◆ xor()

t_gen xor ( t_gen  x,
t_gen  y 
)


Util fuction to complete xor operation between two pointers returns the xor'ed result as a t_gen type

Definition at line 240 of file link_list.c.

Variable Documentation

◆ add

Look Up function ptrs for add based on type of list.

Definition at line 51 of file link_list.c.

◆ append

Look Up function ptrs for apend (add end) based on type of list.

Definition at line 54 of file link_list.c.

◆ del

Look Up function ptrs for delete node based on type of list.

Definition at line 57 of file link_list.c.

◆ del_idx

Look Up function ptrs for delete ith node based on type of list.

Definition at line 60 of file link_list.c.