added support for BD game engine to Makefile for Android
[rocksndiamonds.git] / src / libgame / list.h
1 // ============================================================================
2 // list.h
3 // ============================================================================
4
5 /* GLIB - Library of useful routines for C programming
6  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
7  *
8  * SPDX-License-Identifier: LGPL-2.1-or-later
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
22  */
23
24 /*
25  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
26  * file for a list of people on the GLib Team.  See the ChangeLog
27  * files for a list of changes.  These files are distributed with
28  * GLib at ftp://ftp.gtk.org/pub/gtk/.
29  */
30
31 #ifndef LIST_H
32 #define LIST_H
33
34 #include "misc.h"
35
36
37 typedef struct _List List;
38
39 struct _List
40 {
41   void *data;
42   List *next;
43   List *prev;
44 };
45
46
47 typedef void (*list_fn) (void *data, void *userdata);
48 typedef void *(*list_copy_fn) (const void *data, void *userdata);
49
50 /* Doubly linked lists */
51 List *list_alloc(void);
52 void  list_free(List *list);
53 void  list_free_1(List *list);
54
55 List *list_append(List *list, void *data);
56 List *list_prepend(List *list, void *data);
57 List *list_insert(List *list, void *data, int position);
58 List *list_remove(List *list, const void *data);
59 List *list_remove_all(List *list, const void *data);
60 List *list_remove_link(List *list, List *llink);
61 List *list_delete_link(List *list, List *link_);
62 List *list_reverse(List *list);
63 List *list_copy(List *list);
64 List *list_copy_deep(List *list, list_copy_fn func, void *user_data);
65 List *list_nth(List *list, unsigned int n);
66 List *list_nth_prev(List *list, unsigned int n);
67 int   list_position(List *list, List *llink);
68 int   list_index(List *list, const void *data);
69 List *list_last(List *list);
70 List *list_first(List *list);
71 unsigned int list_length(List *list);
72 void  list_foreach(List *list, list_fn func, void *user_data);
73 void *list_nth_data(List *list, unsigned int n);
74
75 #define list_previous(list)     ((list) ? (((List *)(list))->prev) : NULL)
76 #define list_next(list)         ((list) ? (((List *)(list))->next) : NULL)
77
78 #endif