Skip to content

Commit 116e0ca

Browse files
Functions from linked list moved to vqueue and vstack.
1 parent 0b16ede commit 116e0ca

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

lib_vqueue.h

+14-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
/* add node to queue */
1111
#define vq_enq(pHead) list_ins_head(pHead)
1212

13+
/* push node onto stack - with data */
14+
#define vq_enq_data(pHead, pData) list_ins_head_data(pHead, pData)
15+
1316
/* remove node from queue */
1417
#define vq_deq(pHead) list_rm_node(pHead, list_tail(pHead))
1518

@@ -31,13 +34,22 @@
3134
/* print out contents of queue to stdout */
3235
#define vq_print(pHead) list_print(pHead)
3336

37+
/* reverse contents of list */
38+
#define vq_reverse(pHead) list_reverse(pHead)
39+
3440
/* get address of node at num - first node is 1 */
3541
#define vq_get_num(pHead, count) list_get_num(pHead, count)
3642

43+
/* append high list to last node of low list - does not modify pHi list */
44+
#define vq_append(pLo, pHi) list_append(pLo, pHi)
45+
3746
/* reverse current nodes - modify pointer to next in each */
3847
#define vq_node_swap(pPrev, pCurr) list_node_swap(pPrev, pCurr)
3948

40-
/* reverse contents of list */
41-
#define vq_reverse(pHead) list_reverse(pHead)
49+
/* return an array of pointers to data payload in list - does not modify list */
50+
#define vq_data_array(pHead, pArr, len) list_data_array(pHead, pArr, len)
51+
52+
/* return an array of pointers to nodes in list - does not modify list */
53+
#define vq_node_array(pHead, pArr, len) list_node_array(pHead, pArr, len)
4254

4355
#endif /* LIB_VQUEUE_H_ */

lib_vstack.h

+18
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,22 @@
2828
/* delete and free contents of this queue */
2929
#define vstack_delete(pHead) list_delete(pHead)
3030

31+
/* make a deep copy of list */
32+
#define vstack_copy(pHead) list_copy(pDest, pSrc)
33+
34+
/* print out contents of list to stdout */
35+
#define vstack_print(pHead) list_print(pHead)
36+
37+
/* reverse contents of list */
38+
#define vstack_reverse(pHead) list_reverse(pHead)
39+
40+
/* append high list to last node of low list - does not modify pHi list */
41+
#define vstack_append(pLo, pHi) list_append(pLo, pHi)
42+
43+
/* return an array of pointers to data payload in list - does not modify list */
44+
#define vstack_data_array(pHead, pArr, len) list_data_array(pHead, pArr, len)
45+
46+
/* return an array of pointers to nodes in list - does not modify list */
47+
#define vstack_node_array(pHead, pArr, len) list_node_array(pHead, pArr, len)
48+
3149
#endif /* LIB_VSTACK_H_ */

0 commit comments

Comments
 (0)