1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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 of the License, or (at your option) any later version.
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.
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/>.
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/.
28 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29 #error "Only <glib.h> can be included directly."
32 #include <glib/glist.h>
36 typedef struct _GQueue GQueue
;
40 * @head: a pointer to the first element of the queue
41 * @tail: a pointer to the last element of the queue
42 * @length: the number of elements in the queue
44 * Contains the public fields of a
45 * [Queue][glib-Double-ended-Queues].
57 * A statically-allocated #GQueue must be initialized with this
58 * macro before it can be used. This macro can be used to initialize
59 * a variable, but it cannot be assigned to a variable. In that case
60 * you have to use g_queue_init().
63 * GQueue my_queue = G_QUEUE_INIT;
68 #define G_QUEUE_INIT { NULL, NULL, 0 }
73 GQueue
* g_queue_new (void);
75 void g_queue_free (GQueue
*queue
);
77 void g_queue_free_full (GQueue
*queue
,
78 GDestroyNotify free_func
);
80 void g_queue_init (GQueue
*queue
);
82 void g_queue_clear (GQueue
*queue
);
84 gboolean
g_queue_is_empty (GQueue
*queue
);
86 guint
g_queue_get_length (GQueue
*queue
);
88 void g_queue_reverse (GQueue
*queue
);
90 GQueue
* g_queue_copy (GQueue
*queue
);
92 void g_queue_foreach (GQueue
*queue
,
96 GList
* g_queue_find (GQueue
*queue
,
99 GList
* g_queue_find_custom (GQueue
*queue
,
102 GLIB_AVAILABLE_IN_ALL
103 void g_queue_sort (GQueue
*queue
,
104 GCompareDataFunc compare_func
,
107 GLIB_AVAILABLE_IN_ALL
108 void g_queue_push_head (GQueue
*queue
,
110 GLIB_AVAILABLE_IN_ALL
111 void g_queue_push_tail (GQueue
*queue
,
113 GLIB_AVAILABLE_IN_ALL
114 void g_queue_push_nth (GQueue
*queue
,
117 GLIB_AVAILABLE_IN_ALL
118 gpointer
g_queue_pop_head (GQueue
*queue
);
119 GLIB_AVAILABLE_IN_ALL
120 gpointer
g_queue_pop_tail (GQueue
*queue
);
121 GLIB_AVAILABLE_IN_ALL
122 gpointer
g_queue_pop_nth (GQueue
*queue
,
124 GLIB_AVAILABLE_IN_ALL
125 gpointer
g_queue_peek_head (GQueue
*queue
);
126 GLIB_AVAILABLE_IN_ALL
127 gpointer
g_queue_peek_tail (GQueue
*queue
);
128 GLIB_AVAILABLE_IN_ALL
129 gpointer
g_queue_peek_nth (GQueue
*queue
,
131 GLIB_AVAILABLE_IN_ALL
132 gint
g_queue_index (GQueue
*queue
,
134 GLIB_AVAILABLE_IN_ALL
135 gboolean
g_queue_remove (GQueue
*queue
,
137 GLIB_AVAILABLE_IN_ALL
138 guint
g_queue_remove_all (GQueue
*queue
,
140 GLIB_AVAILABLE_IN_ALL
141 void g_queue_insert_before (GQueue
*queue
,
144 GLIB_AVAILABLE_IN_ALL
145 void g_queue_insert_after (GQueue
*queue
,
148 GLIB_AVAILABLE_IN_ALL
149 void g_queue_insert_sorted (GQueue
*queue
,
151 GCompareDataFunc func
,
154 GLIB_AVAILABLE_IN_ALL
155 void g_queue_push_head_link (GQueue
*queue
,
157 GLIB_AVAILABLE_IN_ALL
158 void g_queue_push_tail_link (GQueue
*queue
,
160 GLIB_AVAILABLE_IN_ALL
161 void g_queue_push_nth_link (GQueue
*queue
,
164 GLIB_AVAILABLE_IN_ALL
165 GList
* g_queue_pop_head_link (GQueue
*queue
);
166 GLIB_AVAILABLE_IN_ALL
167 GList
* g_queue_pop_tail_link (GQueue
*queue
);
168 GLIB_AVAILABLE_IN_ALL
169 GList
* g_queue_pop_nth_link (GQueue
*queue
,
171 GLIB_AVAILABLE_IN_ALL
172 GList
* g_queue_peek_head_link (GQueue
*queue
);
173 GLIB_AVAILABLE_IN_ALL
174 GList
* g_queue_peek_tail_link (GQueue
*queue
);
175 GLIB_AVAILABLE_IN_ALL
176 GList
* g_queue_peek_nth_link (GQueue
*queue
,
178 GLIB_AVAILABLE_IN_ALL
179 gint
g_queue_link_index (GQueue
*queue
,
181 GLIB_AVAILABLE_IN_ALL
182 void g_queue_unlink (GQueue
*queue
,
184 GLIB_AVAILABLE_IN_ALL
185 void g_queue_delete_link (GQueue
*queue
,
190 #endif /* __G_QUEUE_H__ */