-/************************** toolbox/list.h *************************************
+/* src/toolbox/list.h - synchronized linked list
- Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
- See file COPYRIGHT for information on usage and disclaimer of warranties
+ This file is part of CACAO.
- Verwaltung von doppelt verketteten Listen.
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
- Authors: Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
- Last Change: 1996/10/03
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
-*******************************************************************************/
+ Contact: cacao@cacaojvm.org
-#ifndef LIST_H
-#define LIST_H
+ Authors: Reinhard Grafl
-typedef struct listnode { /* Struktur f"ur ein Listenelement */
- struct listnode *next,*prev;
- } listnode;
+ Changes: Christian Thalinger
-typedef struct list { /* Struktur f"ur den Listenkopf */
- listnode *first,*last;
- int nodeoffset;
- } list;
+ $Id: list.h 5049 2006-06-23 12:07:26Z twisti $
+*/
-void list_init (list *l, int nodeoffset);
-void list_addlast (list *l, void *element);
-void list_addfirst (list *l, void *element);
+#ifndef _LIST_H
+#define _LIST_H
-void list_remove (list *l, void *element);
-
-void *list_first (list *l);
-void *list_last (list *l);
+#include "config.h"
+#include "vm/types.h"
-void *list_next (list *l, void *element);
-void *list_prev (list *l, void *element);
+#include "vm/global.h"
-/*
----------------------- Schnittstellenbeschreibung -----------------------------
+/* ---------------------- interface description -----------------------------
-Die Listenverwaltung mit diesem Modul geht so vor sich:
+The list management with this module works like this:
- - jede Struktur, die in die Liste eingeh"angt werden soll, mu"s
- eine Komponente vom Typ 'listnode' haben.
+ - to be used in a list, a structure must have an element of type
+ 'listnode'.
- - es mu"s ein Struktur vom Typ 'list' bereitgestellt werden.
+ - there needs to be a structure of type 'list'.
- - die Funktion list_init (l, nodeoffset) initialisiert diese Struktur,
- dabei gibt der nodeoffset den Offset der 'listnode'-Komponente in
- den Knotenstrukturen an.
+ - the function list_init(l, nodeoffset) initializes the structure.
+ nodeoffset is the offset of the 'listnode' from the start of the
+ structure in bytes.
- - Einf"ugen, Aush"angen und Suchen von Elementen der Liste geht mit
- den "ubrigen Funktionen.
+ - The remaining functions provide inserting, removing and searching.
-Zum besseren Verst"andnis ein kleines Beispiel:
+This small example aims to demonstrate correct usage:
+
void bsp() {
}
- Dieses Programm w"urde also folgendes ausgeben:
+ The output from this program should be:
7
9
11
-Der Grund, warum beim Initialisieren der Liste der Offset mitangegeben
-werden mu"s, ist der da"s ein und das selbe Datenelement gleichzeitig
-in verschiedenen Listen eingeh"angt werden kann (f"ur jede Liste mu"s
-also eine Komponente vom Typ 'listnode' im Element enthalten sein).
+The reason for the usage of 'nodeoffset' is that this way, the same node can
+part of different lists (there must be one 'listnode' element for every
+distinct list).
*/
+/* listnode *******************************************************************/
+
+typedef struct listnode listnode;
+
+struct listnode {
+ listnode *next;
+ listnode *prev;
+};
+
+
+/* list ***********************************************************************/
+
+typedef struct list list;
+
+struct list {
+#if defined(ENABLE_THREADS)
+ java_objectheader lock; /* threads lock object */
#endif
+ listnode *first;
+ listnode *last;
+ s4 nodeoffset;
+};
+
+
+/* function prototypes ********************************************************/
+
+list *list_create(s4 nodeoffset);
+
+void list_add_first(list *l, void *element);
+void list_add_last(list *l, void *element);
+void list_add_last_unsynced(list *l, void *element);
+
+void list_add_before(list *l, void *element, void *newelement);
+
+void list_remove(list *l, void *element);
+
+void *list_first(list *l);
+void *list_last(list *l);
+
+void *list_next(list *l, void *element);
+void *list_prev(list *l, void *element);
+
+#endif /* _LIST_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */