1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * SPDX-License-Identifier: LGPL-2.1-or-later
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
30 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
31 #error "Only <glib.h> can be included directly."
34 #include <glib/glist.h>
38 typedef struct _GQueue GQueue;
42 * @head: a pointer to the first element of the queue
43 * @tail: a pointer to the last element of the queue
44 * @length: the number of elements in the queue
46 * Contains the public fields of a
47 * [Queue][glib-Double-ended-Queues].
59 * A statically-allocated #GQueue must be initialized with this
60 * macro before it can be used. This macro can be used to initialize
61 * a variable, but it cannot be assigned to a variable. In that case
62 * you have to use g_queue_init().
65 * GQueue my_queue = G_QUEUE_INIT;
70 #define G_QUEUE_INIT { NULL, NULL, 0 }
75 GQueue* g_queue_new (void);
77 void g_queue_free (GQueue *queue);
79 void g_queue_free_full (GQueue *queue,
80 GDestroyNotify free_func);
82 void g_queue_init (GQueue *queue);
84 void g_queue_clear (GQueue *queue);
86 gboolean g_queue_is_empty (GQueue *queue);
87 GLIB_AVAILABLE_IN_2_60
88 void g_queue_clear_full (GQueue *queue,
89 GDestroyNotify free_func);
91 guint g_queue_get_length (GQueue *queue);
93 void g_queue_reverse (GQueue *queue);
95 GQueue * g_queue_copy (GQueue *queue);
97 void g_queue_foreach (GQueue *queue,
100 GLIB_AVAILABLE_IN_ALL
101 GList * g_queue_find (GQueue *queue,
103 GLIB_AVAILABLE_IN_ALL
104 GList * g_queue_find_custom (GQueue *queue,
107 GLIB_AVAILABLE_IN_ALL
108 void g_queue_sort (GQueue *queue,
109 GCompareDataFunc compare_func,
112 GLIB_AVAILABLE_IN_ALL
113 void g_queue_push_head (GQueue *queue,
115 GLIB_AVAILABLE_IN_ALL
116 void g_queue_push_tail (GQueue *queue,
118 GLIB_AVAILABLE_IN_ALL
119 void g_queue_push_nth (GQueue *queue,
122 GLIB_AVAILABLE_IN_ALL
123 gpointer g_queue_pop_head (GQueue *queue);
124 GLIB_AVAILABLE_IN_ALL
125 gpointer g_queue_pop_tail (GQueue *queue);
126 GLIB_AVAILABLE_IN_ALL
127 gpointer g_queue_pop_nth (GQueue *queue,
129 GLIB_AVAILABLE_IN_ALL
130 gpointer g_queue_peek_head (GQueue *queue);
131 GLIB_AVAILABLE_IN_ALL
132 gpointer g_queue_peek_tail (GQueue *queue);
133 GLIB_AVAILABLE_IN_ALL
134 gpointer g_queue_peek_nth (GQueue *queue,
136 GLIB_AVAILABLE_IN_ALL
137 gint g_queue_index (GQueue *queue,
139 GLIB_AVAILABLE_IN_ALL
140 gboolean g_queue_remove (GQueue *queue,
142 GLIB_AVAILABLE_IN_ALL
143 guint g_queue_remove_all (GQueue *queue,
145 GLIB_AVAILABLE_IN_ALL
146 void g_queue_insert_before (GQueue *queue,
149 GLIB_AVAILABLE_IN_2_62
150 void g_queue_insert_before_link
154 GLIB_AVAILABLE_IN_ALL
155 void g_queue_insert_after (GQueue *queue,
158 GLIB_AVAILABLE_IN_2_62
159 void g_queue_insert_after_link
163 GLIB_AVAILABLE_IN_ALL
164 void g_queue_insert_sorted (GQueue *queue,
166 GCompareDataFunc func,
169 GLIB_AVAILABLE_IN_ALL
170 void g_queue_push_head_link (GQueue *queue,
172 GLIB_AVAILABLE_IN_ALL
173 void g_queue_push_tail_link (GQueue *queue,
175 GLIB_AVAILABLE_IN_ALL
176 void g_queue_push_nth_link (GQueue *queue,
179 GLIB_AVAILABLE_IN_ALL
180 GList* g_queue_pop_head_link (GQueue *queue);
181 GLIB_AVAILABLE_IN_ALL
182 GList* g_queue_pop_tail_link (GQueue *queue);
183 GLIB_AVAILABLE_IN_ALL
184 GList* g_queue_pop_nth_link (GQueue *queue,
186 GLIB_AVAILABLE_IN_ALL
187 GList* g_queue_peek_head_link (GQueue *queue);
188 GLIB_AVAILABLE_IN_ALL
189 GList* g_queue_peek_tail_link (GQueue *queue);
190 GLIB_AVAILABLE_IN_ALL
191 GList* g_queue_peek_nth_link (GQueue *queue,
193 GLIB_AVAILABLE_IN_ALL
194 gint g_queue_link_index (GQueue *queue,
196 GLIB_AVAILABLE_IN_ALL
197 void g_queue_unlink (GQueue *queue,
199 GLIB_AVAILABLE_IN_ALL
200 void g_queue_delete_link (GQueue *queue,
205 #endif /* __G_QUEUE_H__ */