1 /* src/toolbox/list.h - synchronized linked list
3 Copyright (C) 1996-2005, 2006, 2007 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 $Id: list.h 7596 2007-03-28 21:05:53Z twisti $
36 #include "vm/global.h"
39 /* ---------------------- interface description -----------------------------
41 The list management with this module works like this:
43 - to be used in a list, a structure must have an element of type
46 - there needs to be a structure of type 'list'.
48 - the function list_init(l, nodeoffset) initializes the structure.
49 nodeoffset is the offset of the 'listnode' from the start of the
52 - The remaining functions provide inserting, removing and searching.
54 This small example aims to demonstrate correct usage:
70 list_init (&l, OFFSET(struct node,linkage) );
77 printf ("Element: %d\n", e->value);
83 The output from this program should be:
90 The reason for the usage of 'nodeoffset' is that this way, the same node can
91 part of different lists (there must be one 'listnode' element for every
96 /* listnode *******************************************************************/
98 typedef struct listnode listnode;
106 /* list ***********************************************************************/
108 typedef struct list list;
111 #if defined(ENABLE_THREADS)
112 java_objectheader lock; /* threads lock object */
120 /* function prototypes ********************************************************/
122 list *list_create(s4 nodeoffset);
123 list *list_create_dump(s4 nodeoffset);
125 void list_add_first(list *l, void *element);
127 void list_add_last(list *l, void *element);
128 void list_add_last_unsynced(list *l, void *element);
130 void list_add_before(list *l, void *element, void *newelement);
132 void list_remove(list *l, void *element);
133 void list_remove_unsynced(list *l, void *element);
135 void *list_first(list *l);
136 void *list_first_unsynced(list *l);
138 void *list_last(list *l);
139 void *list_last_unsynced(list *l);
141 void *list_next(list *l, void *element);
142 void *list_next_unsynced(list *l, void *element);
144 void *list_prev(list *l, void *element);
145 void *list_prev_unsynced(list *l, void *element);
151 * These are local overrides for various environment variables in Emacs.
152 * Please do not remove this and leave it at the end of the file, where
153 * Emacs will automagically detect them.
154 * ---------------------------------------------------------------------
157 * indent-tabs-mode: t