3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 Institut f. Computersprachen, TU Wien
5 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Probst,
6 S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich,
9 This file is part of CACAO.
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2, or (at
14 your option) any later version.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 Contact: cacao@complang.tuwien.ac.at
28 Authors: Reinhard Grafl
30 $Id: list.h 684 2003-12-02 16:50:17Z twisti $
38 typedef struct listnode { /* structure for list element */
39 struct listnode *next;
40 struct listnode *prev;
44 typedef struct list { /* structure for list head */
51 /* function prototypes */
53 void list_init(list *l, int nodeoffset);
55 void list_addlast(list *l, void *element);
56 void list_addfirst(list *l, void *element);
58 void list_remove(list *l, void *element);
60 void *list_first(list *l);
61 void *list_last(list *l);
63 void *list_next(list *l, void *element);
64 void *list_prev(list *l, void *element);
68 ---------------------- interface description -----------------------------
70 The list management with this module works like this:
72 - to be used in a list, a structure must have an element of type
75 - there needs to be a structure of type 'list'.
77 - the function list_init(l, nodeoffset) initializes the structure.
78 nodeoffset is the offset of the 'listnode' from the start of the
81 - The remaining functions provide inserting, removing and searching.
83 This small example aims to demonstrate correct usage:
99 list_init (&l, OFFSET(struct node,linkage) );
100 list_addlast (&l, a);
101 list_addlast (&l, b);
102 list_addlast (&l, c);
106 printf ("Element: %d\n", e->value);
107 e = list_next (&l,e);
112 The output from this program should be:
119 The reason for the usage of 'nodeoffset' is that this way, the same node can
120 part of different lists (there must be one 'listnode' element for every
129 * These are local overrides for various environment variables in Emacs.
130 * Please do not remove this and leave it at the end of the file, where
131 * Emacs will automagically detect them.
132 * ---------------------------------------------------------------------
135 * indent-tabs-mode: t