view include/LinkedList.h @ 1:112164f48f30

Cleaned up warnings.
author Eris Caffee <discordia@eldalin.com>
date Wed, 29 Dec 2010 02:44:09 -0600
parents 5db060528d2b
children c9e6f5c0a9b2
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 /* Forward declarations for more traditional C usage. */
56 void ll_init (LinkedList * this);
57 void * ll_push (LinkedList * this, void * data);
58 void * ll_pop (LinkedList * this);
59 void * ll_insert(LinkedList * this, void * data);
60 void * ll_remove(LinkedList * this);
61 void * ll_insert_at_head(LinkedList * this, void * data);
62 int ll_size (LinkedList * this);
63 void * ll_head (LinkedList * this);
64 void * ll_tail (LinkedList * this);
65 void * ll_next (LinkedList * this);
66 void * ll_prev (LinkedList * this);
67 void * ll_data (LinkedList * this);
69 #endif