1 /* src/toolbox/list.h - synchronized linked list
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
33 #include "vm/global.h"
36 /* ---------------------- interface description -----------------------------
38 The list management with this module works like this:
40 - to be used in a list, a structure must have an element of type
43 - there needs to be a structure of type 'list'.
45 - the function list_init(l, nodeoffset) initializes the structure.
46 nodeoffset is the offset of the 'listnode' from the start of the
49 - The remaining functions provide inserting, removing and searching.
51 This small example aims to demonstrate correct usage:
67 list_init (&l, OFFSET(struct node,linkage) );
74 printf ("Element: %d\n", e->value);
80 The output from this program should be:
87 The reason for the usage of 'nodeoffset' is that this way, the same node can
88 part of different lists (there must be one 'listnode' element for every
93 /* listnode_t *****************************************************************/
95 typedef struct listnode_t listnode_t;
103 /* list_t *********************************************************************/
105 typedef struct list_t list_t;
108 #if defined(ENABLE_THREADS)
109 java_object_t lock; /* threads lock object */
114 int size; /* number of elements in the list */
118 /* function prototypes ********************************************************/
120 list_t *list_create(int nodeoffset);
121 list_t *list_create_dump(int nodeoffset);
123 void list_free(list_t *l);
125 void list_lock(list_t *l);
126 void list_unlock(list_t *l);
128 void list_add_first(list_t *l, void *element);
129 void list_add_last(list_t *l, void *element);
130 void list_add_before(list_t *l, void *element, void *newelement);
132 void list_remove(list_t *l, void *element);
134 void *list_first(list_t *l);
135 void *list_last(list_t *l);
137 void *list_next(list_t *l, void *element);
138 void *list_prev(list_t *l, void *element);
144 * These are local overrides for various environment variables in Emacs.
145 * Please do not remove this and leave it at the end of the file, where
146 * Emacs will automagically detect them.
147 * ---------------------------------------------------------------------
150 * indent-tabs-mode: t