1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GLib Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GLib at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __G_SLIST_H__
26#define __G_SLIST_H__
27
28#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29#error "Only <glib.h> can be included directly."
30#endif
31
32#include <glib/gmem.h>
33#include <glib/gnode.h>
34
35G_BEGIN_DECLS
36
37typedef struct _GSList GSList;
38
39struct _GSList
40{
41 gpointer data;
42 GSList *next;
43};
44
45/* Singly linked lists
46 */
47GLIB_AVAILABLE_IN_ALL
48GSList* g_slist_alloc (void) G_GNUC_WARN_UNUSED_RESULT;
49GLIB_AVAILABLE_IN_ALL
50void g_slist_free (GSList *list);
51GLIB_AVAILABLE_IN_ALL
52void g_slist_free_1 (GSList *list);
53#define g_slist_free1 g_slist_free_1
54GLIB_AVAILABLE_IN_ALL
55void g_slist_free_full (GSList *list,
56 GDestroyNotify free_func);
57GLIB_AVAILABLE_IN_ALL
58GSList* g_slist_append (GSList *list,
59 gpointer data) G_GNUC_WARN_UNUSED_RESULT;
60GLIB_AVAILABLE_IN_ALL
61GSList* g_slist_prepend (GSList *list,
62 gpointer data) G_GNUC_WARN_UNUSED_RESULT;
63GLIB_AVAILABLE_IN_ALL
64GSList* g_slist_insert (GSList *list,
65 gpointer data,
66 gint position) G_GNUC_WARN_UNUSED_RESULT;
67GLIB_AVAILABLE_IN_ALL
68GSList* g_slist_insert_sorted (GSList *list,
69 gpointer data,
70 GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT;
71GLIB_AVAILABLE_IN_ALL
72GSList* g_slist_insert_sorted_with_data (GSList *list,
73 gpointer data,
74 GCompareDataFunc func,
75 gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
76GLIB_AVAILABLE_IN_ALL
77GSList* g_slist_insert_before (GSList *slist,
78 GSList *sibling,
79 gpointer data) G_GNUC_WARN_UNUSED_RESULT;
80GLIB_AVAILABLE_IN_ALL
81GSList* g_slist_concat (GSList *list1,
82 GSList *list2) G_GNUC_WARN_UNUSED_RESULT;
83GLIB_AVAILABLE_IN_ALL
84GSList* g_slist_remove (GSList *list,
85 gconstpointer data) G_GNUC_WARN_UNUSED_RESULT;
86GLIB_AVAILABLE_IN_ALL
87GSList* g_slist_remove_all (GSList *list,
88 gconstpointer data) G_GNUC_WARN_UNUSED_RESULT;
89GLIB_AVAILABLE_IN_ALL
90GSList* g_slist_remove_link (GSList *list,
91 GSList *link_) G_GNUC_WARN_UNUSED_RESULT;
92GLIB_AVAILABLE_IN_ALL
93GSList* g_slist_delete_link (GSList *list,
94 GSList *link_) G_GNUC_WARN_UNUSED_RESULT;
95GLIB_AVAILABLE_IN_ALL
96GSList* g_slist_reverse (GSList *list) G_GNUC_WARN_UNUSED_RESULT;
97GLIB_AVAILABLE_IN_ALL
98GSList* g_slist_copy (GSList *list) G_GNUC_WARN_UNUSED_RESULT;
99
100GLIB_AVAILABLE_IN_2_34
101GSList* g_slist_copy_deep (GSList *list,
102 GCopyFunc func,
103 gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
104GLIB_AVAILABLE_IN_ALL
105GSList* g_slist_nth (GSList *list,
106 guint n);
107GLIB_AVAILABLE_IN_ALL
108GSList* g_slist_find (GSList *list,
109 gconstpointer data);
110GLIB_AVAILABLE_IN_ALL
111GSList* g_slist_find_custom (GSList *list,
112 gconstpointer data,
113 GCompareFunc func);
114GLIB_AVAILABLE_IN_ALL
115gint g_slist_position (GSList *list,
116 GSList *llink);
117GLIB_AVAILABLE_IN_ALL
118gint g_slist_index (GSList *list,
119 gconstpointer data);
120GLIB_AVAILABLE_IN_ALL
121GSList* g_slist_last (GSList *list);
122GLIB_AVAILABLE_IN_ALL
123guint g_slist_length (GSList *list);
124GLIB_AVAILABLE_IN_ALL
125void g_slist_foreach (GSList *list,
126 GFunc func,
127 gpointer user_data);
128GLIB_AVAILABLE_IN_ALL
129GSList* g_slist_sort (GSList *list,
130 GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT;
131GLIB_AVAILABLE_IN_ALL
132GSList* g_slist_sort_with_data (GSList *list,
133 GCompareDataFunc compare_func,
134 gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
135GLIB_AVAILABLE_IN_ALL
136gpointer g_slist_nth_data (GSList *list,
137 guint n);
138
139GLIB_AVAILABLE_IN_2_64
140void g_clear_slist (GSList **slist_ptr,
141 GDestroyNotify destroy);
142
143#define g_clear_slist(slist_ptr, destroy) \
144 G_STMT_START { \
145 GSList *_slist; \
146 \
147 _slist = *(slist_ptr); \
148 if (_slist) \
149 { \
150 *slist_ptr = NULL; \
151 \
152 if ((destroy) != NULL) \
153 g_slist_free_full (_slist, (destroy)); \
154 else \
155 g_slist_free (_slist); \
156 } \
157 } G_STMT_END \
158 GLIB_AVAILABLE_MACRO_IN_2_64
159
160#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL)
161
162G_END_DECLS
163
164#endif /* __G_SLIST_H__ */
165

source code of gtk/subprojects/glib/glib/gslist.h