-
Notifications
You must be signed in to change notification settings - Fork 0
/
llist.h
86 lines (71 loc) · 2.03 KB
/
llist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef LLIST_H
#define LLIST_H
typedef struct _node node;
struct _node {
void *item;
node *next;
};
typedef struct _llist {
node *head;
node *tail;
} llist;
/* create_list
* purpose: create a linked list structure and initialize to empty list
* inputs: none
* outputs: pointer to newly created and initialized linked list
*/
llist *create_llist();
/* insert_head
* purpose: insert an item to become the first item in a linked list.
* inputs:
* list - pointer to llist struct in which to insert item
* item - a pointer to the item to be inserted into the linked list
* return: nothing
*/
void insert_head(llist *list, void *item);
/* remove_head
* purpose: remove the item that is at the beginning of a linked list
* inputs:
* list - pointer to llist struct in which to insert item
* return:
*/
void remove_head(llist *list);
/* peek_head
* purpose: return the first item in a linked list
* inputs:
* list - pointer to llist struct in which to insert item
* return:
* void * - the first item stored in the linked list
*/
void *peek_head(llist *list);
/* insert_tail
* purpose: insert an item to become the last item in a linked list.
* inputs:
* list - pointer to llist struct in which to insert item
* item - a pointer to the item to be inserted into the linked list
* return: nothing
*/
void insert_tail(llist *list, void *item);
/* remove_tail
* purpose: remove the item that is at the beginning of a linked list
* inputs:
* list - pointer to llist struct in which to insert item
* return: nothing
*/
void remove_tail(llist *list);
/* peek_tail
* purpose: return the last item in a linked list
* inputs:
* list - pointer to llist struct in which to insert item
* return:
* void * - the last item stored in the linked list (which is a pointer)
*/
void *peek_tail(llist *list);
/* list_is_empty
* purpose: return a pseudo-boolean indicating whether or not the
* list is empty
* input: list
* output: 0 if not empty, nonzero if empty
*/
int list_is_empty(llist *list);
#endif