view include/LinkedList.h @ 0:5db060528d2b

Initial import
author Eris Caffee <discordia@eldalin.com>
date Wed, 29 Dec 2010 02:14:35 -0600
parents
children 112164f48f30
line source
1 /*******************************************************************************
2 * linked_list
3 *
4 * A simple doubly linked list class in C.
5 *
6 * Not thread safe.
7 *
8 * Since this class does not attempt to manage memory for the actual stored
9 * objects, there is no "clear" method to delete the entire list. Instead,
10 * the user must pop the entire list and delete the individually returned
11 * objects one at a time.
12 *
13 * A potential improvement would be to allow the registration of an object
14 * destructor at list creation which could then be used by a clear() method.
15 *
16 *
17 *
18 *
19 * OOH SHINY!
20 * http://tinobox.com/wordpress/object-oriented-c-coding/
21 *
22 * Looks liks good stuff. Must read.
23 *
24 ******************************************************************************/
26 #ifndef LINKEDLIST_H
27 #define LINKEDLIST_H
29 typedef struct ll_node ll_node;
31 typedef struct LinkedList LinkedList;
32 struct LinkedList
33 {
34 /* Public */
35 void * (* push) (LinkedList * this, void * data);
36 void * (* pop) (LinkedList * this);
37 void * (* insert)(LinkedList * this, void * data);
38 void * (* remove)(LinkedList * this);
39 void * (* insert_at_head)(LinkedList * this, void * data);
40 int (* size) (LinkedList * this);
41 void * (* head) (LinkedList * this);
42 void * (* tail) (LinkedList * this);
43 void * (* next) (LinkedList * this);
44 void * (* prev) (LinkedList * this);
45 void * (* data) (LinkedList * this);
47 /* Private (notionally, at least) */
48 ll_node * Head;
49 ll_node * Curr;
50 ll_node * Tail;
51 int Size;
52 };
54 #endif