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
37 #include "vm/global.h"
40 /* ---------------------- interface description -----------------------------
42 The list management with this module works like this:
44 - to be used in a list, a structure must have an element of type
47 - there needs to be a structure of type 'list'.
49 - the function list_init(l, nodeoffset) initializes the structure.
50 nodeoffset is the offset of the 'listnode' from the start of the
53 - The remaining functions provide inserting, removing and searching.
55 This small example aims to demonstrate correct usage:
71 list_init (&l, OFFSET(struct node,linkage) );
78 printf ("Element: %d\n", e->value);
84 The output from this program should be:
91 The reason for the usage of 'nodeoffset' is that this way, the same node can
92 part of different lists (there must be one 'listnode' element for every
97 /* listnode_t *****************************************************************/
99 typedef struct listnode_t listnode_t;
107 /* list_t *********************************************************************/
109 typedef struct list_t list_t;
112 #if defined(ENABLE_THREADS)
113 java_object_t lock; /* threads lock object */
118 int size; /* number of elements in the list */
122 /* function prototypes ********************************************************/
124 list_t *list_create(int nodeoffset);
125 list_t *list_create_dump(int nodeoffset);
127 void list_free(list_t *l);
129 void list_lock(list_t *l);
130 void list_unlock(list_t *l);
132 void list_add_first(list_t *l, void *element);
133 void list_add_last(list_t *l, void *element);
134 void list_add_before(list_t *l, void *element, void *newelement);
136 void list_remove(list_t *l, void *element);
138 void *list_first(list_t *l);
139 void *list_last(list_t *l);
141 void *list_next(list_t *l, void *element);
142 void *list_prev(list_t *l, void *element);
152 * These are local overrides for various environment variables in Emacs.
153 * Please do not remove this and leave it at the end of the file, where
154 * Emacs will automagically detect them.
155 * ---------------------------------------------------------------------
158 * indent-tabs-mode: t