1 /* src/toolbox/list.h - synchronized linked list
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, 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., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Reinhard Grafl
29 Changes: Christian Thalinger
31 $Id: list.h 5894 2006-11-02 12:54:15Z twisti $
42 #include "vm/global.h"
45 /* ---------------------- interface description -----------------------------
47 The list management with this module works like this:
49 - to be used in a list, a structure must have an element of type
52 - there needs to be a structure of type 'list'.
54 - the function list_init(l, nodeoffset) initializes the structure.
55 nodeoffset is the offset of the 'listnode' from the start of the
58 - The remaining functions provide inserting, removing and searching.
60 This small example aims to demonstrate correct usage:
76 list_init (&l, OFFSET(struct node,linkage) );
83 printf ("Element: %d\n", e->value);
89 The output from this program should be:
96 The reason for the usage of 'nodeoffset' is that this way, the same node can
97 part of different lists (there must be one 'listnode' element for every
102 /* listnode *******************************************************************/
104 typedef struct listnode listnode;
112 /* list ***********************************************************************/
114 typedef struct list list;
117 #if defined(ENABLE_THREADS)
118 java_objectheader lock; /* threads lock object */
126 /* function prototypes ********************************************************/
128 list *list_create(s4 nodeoffset);
129 list *list_create_dump(s4 nodeoffset);
131 void list_add_first(list *l, void *element);
133 void list_add_last(list *l, void *element);
134 void list_add_last_unsynced(list *l, void *element);
136 void list_add_before(list *l, void *element, void *newelement);
138 void list_remove(list *l, void *element);
140 void *list_first(list *l);
141 void *list_first_unsynced(list *l);
143 void *list_last(list *l);
144 void *list_last_unsynced(list *l);
146 void *list_next(list *l, void *element);
147 void *list_next_unsynced(list *l, void *element);
149 void *list_prev(list *l, void *element);
150 void *list_prev_unsynced(list *l, void *element);
156 * These are local overrides for various environment variables in Emacs.
157 * Please do not remove this and leave it at the end of the file, where
158 * Emacs will automagically detect them.
159 * ---------------------------------------------------------------------
162 * indent-tabs-mode: t