135 if (l->
head == NULL) {
164 if (l->
head != NULL) {
195 if (l->
tail != NULL) {
223 if (l->
tail != NULL) {
242 return (
t_gen)((uintptr_t)(x) ^ (uintptr_t)(y));
270 if (l->
head == NULL) {
294 if (l->
head == NULL) {
319 node->
prv = node->
nxt = NULL;
321 if (l->
head == NULL) {
350 if (l->
head == NULL) {
377 node->
prv = node->
nxt = NULL;
379 if (l->
head == NULL) {
412 if (l->
head == NULL) {
439 if (l->
head == NULL) {
462 LOG_INFO(
"LINK_LIST",
"%s: No node found within the link list\n",l->
name);
470 if (prv->nxt == NULL) {
498 if (l->
head == NULL) {
506 if (l->
head != NULL) {
512 cur->
nxt = cur->
prv = NULL;
523 LOG_INFO(
"LINK_LIST",
"%s: No node found within the link list\n",l->
name);
530 if (cur->
nxt == NULL) {
540 cur->
nxt = cur->
prv = NULL;
563 if (l->
head == NULL) {
589 if (cur == l->
head) {
590 LOG_INFO(
"LINK_LIST",
"%s: No node found within the link list\n",l->
name);
599 if (prv->nxt == l->
head) {
626 if (l->
head == NULL) {
642 cur->
nxt = cur->
prv = NULL;
652 LOG_INFO(
"LINK_LIST",
"%s: No node found within the link list\n",l->
name);
669 cur->
nxt = cur->
prv = NULL;
685 t_llnode *prev = NULL , *next = NULL;
690 if (l->
head == NULL) {
702 if (l->
head != NULL) {
721 next =
xor(cur->
nxt, prev);
724 LOG_INFO(
"LINK_LIST",
"%s: No node found within the link list\n",l->
name);
732 next =
xor(cur->
nxt, prev);
743 next->
nxt =
xor(prev,
xor(next->nxt, cur));
771 if (l->
head == NULL) {
776 if (idx >= l->
count && idx < 0) {
777 LOG_WARN(
"LINK_LIST",
"%d: Index out of bounds, number of nodes that exist = %d\n",idx, l->
count);
781 for(
int i = 0; i < idx; i++) {
796 if (prv->nxt == NULL) {
825 if (l->
head == NULL) {
831 if (idx >= l->
count && idx < 0) {
832 LOG_WARN(
"LINK_LIST",
"%d: Index out of bounds, number of nodes that exist = %d\n",idx, l->
count);
836 for(
int i = 0; i < idx ; i ++) {
842 if (l->
head != NULL) {
853 if (cur->
nxt == NULL) {
864 cur->
nxt = cur->
prv = NULL;
886 if (l->
head == NULL) {
891 if (idx >= l->
count && idx < 0) {
892 LOG_WARN(
"LINK_LIST",
"%d: Index out of bounds, number of nodes that exist = %d\n",idx, l->
count);
896 for(
int i = 0; i < idx; i ++) {
901 if (cur == l->
head) {
902 LOG_INFO(
"LINK_LIST",
"%s: No node of index %d found within the link list\n",l->
name, idx);
926 if (prv->nxt == l->
head) {
954 if (l->
head == NULL) {
960 if (idx >= l->
count && idx < 0) {
961 LOG_WARN(
"LINK_LIST",
"%d: Index out of bounds, number of nodes that exist = %d\n",idx, l->
count);
965 for(
int i = 0; i < idx; i ++) {
968 LOG_INFO(
"LINK_LIST",
"%s: No node of index %d found within the link list\n",l->
name, idx);
984 cur->
nxt = cur->
prv = NULL;
1004 cur->
nxt = cur->
prv = NULL;
1026 if (l->
head == NULL) {
1031 if (idx >= l->
count && idx < 0) {
1032 LOG_WARN(
"LINK_LIST",
"%d: Index out of bounds, number of nodes that exist = %d\n",idx, l->
count);
1037 for(
int i = 0; i < idx; i++) {
1050 if (l->
head != NULL) {
1061 next =
xor(cur->
nxt, prv);
1064 prv->nxt =
xor(next,
xor(prv->nxt, cur)) ;
1072 next->
nxt =
xor(prv,
xor(next->nxt, cur));
1112 if ((idx < 0) || (idx >= l->
count)) {
1117 for (i = 0; i < idx; i++) {
1230 prev = (l->
head == node)? NULL: prev;
1231 next =
xor(node->
nxt, prev);
1267 next = (l->
tail == node)? NULL: next;
1268 prev =
xor(node->nxt, next);
1286 return "SINGLE_LINKLIST";
1288 return "DOUBLE_LINKLIST";
1290 return "SINGLE_CIRCULAR_LINKLIST";
1292 return "DOUBLE_CIRCULAR_LINKLIST";
1294 return "XOR_LINKLIST";
1311 printf(
"%s : [", l->
name);
1344 printf(
"%s:%s {Head: %lx} {Tail: %lx} {count: %u}\n[",l->
name,
1353 printf(
"[ %lx ", (
long)ptr->
prv);
1355 printf(
" %lx]", (
long)ptr->
nxt);
1390 tmp->
nxt = tmp->
prv = NULL;
1391 l->
free(tmp->
data, __FILE__, __LINE__);
1398 if (l->
count != 0) {
t_gen del_node_dcll(t_gen d, t_gen data)
Delete node with matching data in Doubly Circular LL and return the instance
t_gen del_node_xor_dll(t_gen d, t_gen data)
Delete node with matching data in xor link list
t_gen del_node_dcll_idx(t_gen d, int idx)
Delete node with matching index in Doubly Circular LL and return the instance
void add_end_xor_dll(t_gen d, t_gen data)
add end in xor link list
f_del_idx del_idx[]
Look Up function ptrs for delete ith node based on type of list.
t_gen linklist_get_prev(t_gen, t_gen)
Get the prev node of given node in link list limitation for xor prev node be it iterrates from tail m...
void linklist_print_info(t_gen d)
Print the elem in linklist with linkinfo
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
char * get_lltype_name(e_lltype type)
f_ins append[]
Look Up function ptrs for apend (add end) based on type of list.
void linklist_print(t_gen d)
Print the elems of link list
t_gen del_node_dll_idx(t_gen d, int idx)
Delete node with matching index in Doublly LL and return the instance
void add_begin_xor_dll(t_gen d, t_gen data)
Add begin in xor link list
f_ins add[]
Look Up function ptrs for add based on type of list.
t_gen del_node_xor_idx(t_gen d, int idx)
Delete node with matching index in XOR LL and return the instance
int linklist_length(t_gen d)
Length of the link list
f_del del[]
Look Up function ptrs for delete node based on type of list.
t_gen del_node_scll(t_gen d, t_gen data)
Delete node with matching data in Singly Circular LL and return the instance
void add_begin_scll(t_gen d, t_gen data)
Add Beggining for Singly Circular LL
void add_begin_dcll(t_gen d, t_gen data)
Add Beggining for Doubly Circular LL
t_gen del_node_sll_idx(t_gen d, int idx)
Delete node with matching index in singly LL and return the instance
t_gen del_node_dll(t_gen d, t_gen data)
Delete node with matching data in Doublly LL and return the instance
void add_end_scll(t_gen d, t_gen data)
Add End for Singly Circular LL
t_gen del_node_sll(t_gen d, t_gen data)
Delete node with matching data in singly LL and return the instance
void add_begin_dll(t_gen d, t_gen data)
Add Beggining for doubly LL
t_gen linklist_get_end(t_gen)
Get the end of link list
void add_end_dcll(t_gen d, t_gen data)
Add End for Doubly Circular LL
void destroy_link_list(t_gen d)
Destroy instance of the LL
t_gen create_link_list(char *name, e_lltype type, t_dparams *prm)
Create an instance of link list
t_gen linklist_get_node_data(t_gen)
Fetch node data;
void add_end_dll(t_gen d, t_gen data)
Add End for Doublly LL
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.
t_gen linklist_get_head(t_gen)
Get the head node of link list
t_gen del_node_scll_idx(t_gen d, int idx)
Delete node with matching index in Singly Circular LL and return the instance
t_gen linklist_get_tail(t_gen)
Get the tail node of link list
t_gen linklist_find(t_gen d, t_gen data)
Brief description. Find data in the link list.
void add_end_sll(t_gen d, t_gen data)
Add End for Singly LL
void add_begin_sll(t_gen d, t_gen data)
Add Beggining for singly LL
t_gen linklist_get_next(t_gen, t_gen)
Get the next node of given node in link list limitation for xor next node be it iterrates from head m...
Contains declations of link list types, node and link list structure.
e_lltype
Type of linklists.
@ eSINGLE_CIRCULAR_LINKLIST
Singly Circular Link list.
@ eDOUBLE_LINKLIST
Doubly Link list.
@ eDOUBLE_CIRCULAR_LINKLIST
Doubly Circular Link list.
@ eXOR_LINKLIST
Xor Link list.
@ eSINGLE_LINKLIST
Singly Link list
#define LOG_INFO(mod, fmt, args...)
#define LOG_ERROR(mod, fmt, args...)
#define LOG_WARN(mod, fmt, args...)
#define free_mem(mem_addr)
#define get_mem(nmemb, size)
f_cmpr cmpr
Routine used for comparing two given elems of said type.
f_swap swap
Routine used for swaping two elemnts of goven data.
f_free free
Routine used for freeing elements of said data.
f_print print_data
Routine used for printing elem data.
Link List main structure.
f_find find
routine to find and get the node with matching elem
f_ins add
routine to Add elem at begin of link list
f_gen2 next_node
routine to get the next node of the given node
f_len len
routine to get len of link list
f_print print_info
routine to print the detailed of link list
f_get_idx get_idx
routine to get node at idx
f_ins append
routine to Add elem at end of link list
f_print print
routine to print the link list
t_llnode * head
Head node reference.
char * name
Name of link list instance */.
f_destroy destroy
routine destroy the link list instance
f_gen head_node
routine to get the head node
f_del_idx del_idx
routine to del node at idx
f_gen2 prev_node
routine to get the prev node of the given node
f_print print_data
routies for operating on data
e_lltype type
Type of link list.
f_gen end_node
routine to get the end node
t_llnode * tail
Tail node reference.
f_gen tail_node
routine to get the tail node
f_del del
routine to del node with matching elem of link list
int count
Total no of elems stored in link list.
f_gen get_node_data
routine to get data in given node
Link list node definition.
t_gen data
Pointer to the data to be stored in link list.
struct llnode * prv
Pointer to prev node in list.
struct llnode * nxt
Pointer to next node in list.
void * t_gen
Base Data type used for all data structure and data elements.
f_vgen2 f_ins
fn type of insert elem function
f_genidx f_del_idx
fn type of get elem at idx function
f_gen2 f_del
fn type of delete elem function