-
Notifications
You must be signed in to change notification settings - Fork 0
/
itemlist.h
64 lines (47 loc) · 1.58 KB
/
itemlist.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
#ifndef ITEMLIST_H
#define ITEMLIST_H
#include <stdlib.h>
typedef struct itemlistnode *ItemLink;
typedef struct itemlist *ItemList;
/* Item that composes the lists. */
#define Item Task
#include "task.h"
#define freeItem(A) freeTask(A)
#define key(A) getId(A)
struct itemlistnode {
Item item;
ItemLink previous;
ItemLink next;
};
struct itemlist {
ItemLink head;
ItemLink last;
};
/* Allocates and initializes values for a new ItemList, returns
its pointer. */
ItemList initItemList();
/* Appends item to the list. Returns the link to the node
to make operations possible. */
ItemLink addItemToList(ItemList list, Item item);
/* Frees a single ItemLink in the list. */
void freeItemLink(ItemList list, ItemLink link);
/* Frees all ItemLink in the list. */
void freeItemLinks(ItemList list);
/* Returns the ItemLink with the correspondant searchValue. */
ItemLink findItemLink(ItemList list, unsigned long searchValue);
/* Given an ItemLink, returns the Item of the node. */
Item getItem(ItemLink link);
/* Given an ItemList, returns the first ItemLink of it. */
ItemLink getFirstLinkIL(ItemList list);
/* Given an ItemList, returns the last ItemLink of it. */
ItemLink getLastLinkIL(ItemList list);
/* Given an ItemLink, returns the next ItemLink. */
ItemLink getNextItemLink(ItemLink link);
/* Given an ItemLink returns the previous ItemLink. */
ItemLink getPrevItemLink(ItemLink link);
/* Returns if the ItemList is empty or not. */
int isEmptyIL(ItemList list);
/* Prints the key of each item on list, by the order
they were added. */
void printItemKeys(ItemList list);
#endif