-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.h
53 lines (42 loc) · 1.25 KB
/
list.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
#ifndef ylaciexpr_list_h
#define ylaciexpr_list_h
#include <stdbool.h>
typedef int (*VALUE_COMPARER)(const void *, const void *);
typedef struct list_node ListNode;
typedef struct list_ {
ListNode* head;
unsigned long size;
VALUE_COMPARER comparer;
unsigned int traversing;
} List;
struct list_node {
void *value;
ListNode *next;
};
typedef enum list_iteration_state_t {
LITST_UNKNOWN = 0,
LITST_BEFORE,
LITST_RUNNING,
LITST_AFTER
} ListIterationState;
typedef struct {
List *list;
ListNode *current;
ListIterationState state;
} ListIterator;
List *List_new(VALUE_COMPARER comparer);
void List_delete(List *list);
const unsigned long List_size(const List *list);
const bool List_is_empty(const List *list);
bool List_add(List *list, void *value);
void *List_get(const List *list, const void *value);
void *List_get_at(const List *list, const unsigned long index);
bool List_remove(List *list, void *value);
bool List_remove_at(List *list, unsigned long index);
ListIterator *List_iterator(List *list);
ListIterator *ListIter_new(List *list);
void ListIter_delete(ListIterator *iter);
void *ListIter_current(const ListIterator *iter);
bool ListIter_move_next(ListIterator *iter);
#endif
/* vim: set et ts=4 sw=4 sts=4: */