1 // ============================================================================
3 // ============================================================================
5 /* GLIB - Library of useful routines for C programming
6 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
8 * SPDX-License-Identifier: LGPL-2.1-or-later
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.
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.
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/>.
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/.
37 typedef struct _List List;
47 typedef void (*list_fn) (void *data, void *userdata);
48 typedef void *(*list_copy_fn) (const void *data, void *userdata);
50 /* Doubly linked lists */
51 List *list_alloc(void);
52 void list_free(List *list);
53 void list_free_1(List *list);
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);
75 #define list_previous(list) ((list) ? (((List *)(list))->prev) : NULL)
76 #define list_next(list) ((list) ? (((List *)(list))->next) : NULL)