3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
29 $Id: list.h 1735 2004-12-07 14:33:27Z twisti $
37 typedef struct listnode { /* structure for list element */
38 struct listnode *next;
39 struct listnode *prev;
43 typedef struct list { /* structure for list head */
50 /* function prototypes */
52 void list_init(list *l, int nodeoffset);
54 void list_addlast(list *l, void *element);
55 void list_addfirst(list *l, void *element);
57 void list_remove(list *l, void *element);
59 void *list_first(list *l);
60 void *list_last(list *l);
62 void *list_next(list *l, void *element);
63 void *list_prev(list *l, void *element);
67 ---------------------- interface description -----------------------------
69 The list management with this module works like this:
71 - to be used in a list, a structure must have an element of type
74 - there needs to be a structure of type 'list'.
76 - the function list_init(l, nodeoffset) initializes the structure.
77 nodeoffset is the offset of the 'listnode' from the start of the
80 - The remaining functions provide inserting, removing and searching.
82 This small example aims to demonstrate correct usage:
98 list_init (&l, OFFSET(struct node,linkage) );
100 list_addlast (&l, b);
101 list_addlast (&l, c);
105 printf ("Element: %d\n", e->value);
106 e = list_next (&l,e);
111 The output from this program should be:
118 The reason for the usage of 'nodeoffset' is that this way, the same node can
119 part of different lists (there must be one 'listnode' element for every
128 * These are local overrides for various environment variables in Emacs.
129 * Please do not remove this and leave it at the end of the file, where
130 * Emacs will automagically detect them.
131 * ---------------------------------------------------------------------
134 * indent-tabs-mode: t