Tenncor
list.h
Go to the documentation of this file.
1 
9 #include <assert.h>
10 #include <stdlib.h>
11 
12 #ifndef PARSE_LIST_H
13 #define PARSE_LIST_H
14 
16 struct NumNode
17 {
19  struct NumNode* next_;
20 
22  double val_;
23 };
24 
26 struct NumList
27 {
29  struct NumNode* head_;
30 
32  struct NumNode* tail_;
33 };
34 
36 struct NumList* new_numlist (void);
37 
39 void numlist_clear (struct NumList* list);
40 
42 void numlist_free (struct NumList* list);
43 
45 void numlist_pushback (struct NumList* list, double val);
46 
47 
49 struct PtrNode
50 {
52  struct PtrNode* next_;
53 
55  void* val_;
56 };
57 
59 struct PtrList
60 {
62  struct PtrNode* head_;
63 
65  struct PtrNode* tail_;
66 
68  size_t type_;
69 };
70 
72 struct PtrList* new_ptrlist (size_t type);
73 
77 void ptrlist_clear (struct PtrList* list, void (*val_mgr)(void*));
78 
80 void ptrlist_free (struct PtrList* list, void (*val_mgr)(void*));
81 
83 void ptrlist_pushback (struct PtrList* list, void* val);
84 
85 #endif // PARSE_LIST_H
struct NumList * new_numlist(void)
Return a new decimal linked list.
Pointer linked list.
Definition: list.h:59
void numlist_free(struct NumList *list)
Clear list then free the list.
double val_
Stored decimal value.
Definition: list.h:22
void * val_
Stored pointer value.
Definition: list.h:55
struct NumNode * head_
Head of the linked list.
Definition: list.h:29
struct NumNode * next_
Next node in list (null denoting end of list)
Definition: list.h:19
Decimal linked list.
Definition: list.h:26
void numlist_clear(struct NumList *list)
Free all nodes in list and reset list head and tail to null.
struct PtrNode * tail_
Tail of the linked list (tail_.next_ should be null)
Definition: list.h:65
size_t type_
Enumerated type of stored pointer.
Definition: list.h:68
void ptrlist_clear(struct PtrList *list, void(*val_mgr)(void *))
void ptrlist_pushback(struct PtrList *list, void *val)
Append the pointer to the list.
struct PtrList * new_ptrlist(size_t type)
Return a new pointer list of specified enumerated type.
Node of a decimal linked list.
Definition: list.h:16
Node of a pointer linked list.
Definition: list.h:49
struct PtrNode * head_
Head of the linked list.
Definition: list.h:62
struct PtrNode * next_
Next node in list (null denoting end of list)
Definition: list.h:52
struct NumNode * tail_
Tail of the linked list (tail_.next_ should be null)
Definition: list.h:32
void numlist_pushback(struct NumList *list, double val)
Append val to linked list.
void ptrlist_free(struct PtrList *list, void(*val_mgr)(void *))
Clear the list using val_mgr, then free the list.