1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
20/*
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/.
25 */
26
27#ifndef __G_QUEUE_H__
28#define __G_QUEUE_H__
29
30#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
31#error "Only <glib.h> can be included directly."
32#endif
33
34#include <glib/glist.h>
35
36G_BEGIN_DECLS
37
38typedef struct _GQueue GQueue;
39
40/**
41 * 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
45 *
46 * Contains the public fields of a
47 * [Queue][glib-Double-ended-Queues].
48 */
49struct _GQueue
50{
51 GList *head;
52 GList *tail;
53 guint length;
54};
55
56/**
57 * G_QUEUE_INIT:
58 *
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().
63 *
64 * |[
65 * GQueue my_queue = G_QUEUE_INIT;
66 * ]|
67 *
68 * Since: 2.14
69 */
70#define G_QUEUE_INIT { NULL, NULL, 0 }
71
72/* Queues
73 */
74GLIB_AVAILABLE_IN_ALL
75GQueue* g_queue_new (void);
76GLIB_AVAILABLE_IN_ALL
77void g_queue_free (GQueue *queue);
78GLIB_AVAILABLE_IN_ALL
79void g_queue_free_full (GQueue *queue,
80 GDestroyNotify free_func);
81GLIB_AVAILABLE_IN_ALL
82void g_queue_init (GQueue *queue);
83GLIB_AVAILABLE_IN_ALL
84void g_queue_clear (GQueue *queue);
85GLIB_AVAILABLE_IN_ALL
86gboolean g_queue_is_empty (GQueue *queue);
87GLIB_AVAILABLE_IN_2_60
88void g_queue_clear_full (GQueue *queue,
89 GDestroyNotify free_func);
90GLIB_AVAILABLE_IN_ALL
91guint g_queue_get_length (GQueue *queue);
92GLIB_AVAILABLE_IN_ALL
93void g_queue_reverse (GQueue *queue);
94GLIB_AVAILABLE_IN_ALL
95GQueue * g_queue_copy (GQueue *queue);
96GLIB_AVAILABLE_IN_ALL
97void g_queue_foreach (GQueue *queue,
98 GFunc func,
99 gpointer user_data);
100GLIB_AVAILABLE_IN_ALL
101GList * g_queue_find (GQueue *queue,
102 gconstpointer data);
103GLIB_AVAILABLE_IN_ALL
104GList * g_queue_find_custom (GQueue *queue,
105 gconstpointer data,
106 GCompareFunc func);
107GLIB_AVAILABLE_IN_ALL
108void g_queue_sort (GQueue *queue,
109 GCompareDataFunc compare_func,
110 gpointer user_data);
111
112GLIB_AVAILABLE_IN_ALL
113void g_queue_push_head (GQueue *queue,
114 gpointer data);
115GLIB_AVAILABLE_IN_ALL
116void g_queue_push_tail (GQueue *queue,
117 gpointer data);
118GLIB_AVAILABLE_IN_ALL
119void g_queue_push_nth (GQueue *queue,
120 gpointer data,
121 gint n);
122GLIB_AVAILABLE_IN_ALL
123gpointer g_queue_pop_head (GQueue *queue);
124GLIB_AVAILABLE_IN_ALL
125gpointer g_queue_pop_tail (GQueue *queue);
126GLIB_AVAILABLE_IN_ALL
127gpointer g_queue_pop_nth (GQueue *queue,
128 guint n);
129GLIB_AVAILABLE_IN_ALL
130gpointer g_queue_peek_head (GQueue *queue);
131GLIB_AVAILABLE_IN_ALL
132gpointer g_queue_peek_tail (GQueue *queue);
133GLIB_AVAILABLE_IN_ALL
134gpointer g_queue_peek_nth (GQueue *queue,
135 guint n);
136GLIB_AVAILABLE_IN_ALL
137gint g_queue_index (GQueue *queue,
138 gconstpointer data);
139GLIB_AVAILABLE_IN_ALL
140gboolean g_queue_remove (GQueue *queue,
141 gconstpointer data);
142GLIB_AVAILABLE_IN_ALL
143guint g_queue_remove_all (GQueue *queue,
144 gconstpointer data);
145GLIB_AVAILABLE_IN_ALL
146void g_queue_insert_before (GQueue *queue,
147 GList *sibling,
148 gpointer data);
149GLIB_AVAILABLE_IN_2_62
150void g_queue_insert_before_link
151 (GQueue *queue,
152 GList *sibling,
153 GList *link_);
154GLIB_AVAILABLE_IN_ALL
155void g_queue_insert_after (GQueue *queue,
156 GList *sibling,
157 gpointer data);
158GLIB_AVAILABLE_IN_2_62
159void g_queue_insert_after_link
160 (GQueue *queue,
161 GList *sibling,
162 GList *link_);
163GLIB_AVAILABLE_IN_ALL
164void g_queue_insert_sorted (GQueue *queue,
165 gpointer data,
166 GCompareDataFunc func,
167 gpointer user_data);
168
169GLIB_AVAILABLE_IN_ALL
170void g_queue_push_head_link (GQueue *queue,
171 GList *link_);
172GLIB_AVAILABLE_IN_ALL
173void g_queue_push_tail_link (GQueue *queue,
174 GList *link_);
175GLIB_AVAILABLE_IN_ALL
176void g_queue_push_nth_link (GQueue *queue,
177 gint n,
178 GList *link_);
179GLIB_AVAILABLE_IN_ALL
180GList* g_queue_pop_head_link (GQueue *queue);
181GLIB_AVAILABLE_IN_ALL
182GList* g_queue_pop_tail_link (GQueue *queue);
183GLIB_AVAILABLE_IN_ALL
184GList* g_queue_pop_nth_link (GQueue *queue,
185 guint n);
186GLIB_AVAILABLE_IN_ALL
187GList* g_queue_peek_head_link (GQueue *queue);
188GLIB_AVAILABLE_IN_ALL
189GList* g_queue_peek_tail_link (GQueue *queue);
190GLIB_AVAILABLE_IN_ALL
191GList* g_queue_peek_nth_link (GQueue *queue,
192 guint n);
193GLIB_AVAILABLE_IN_ALL
194gint g_queue_link_index (GQueue *queue,
195 GList *link_);
196GLIB_AVAILABLE_IN_ALL
197void g_queue_unlink (GQueue *queue,
198 GList *link_);
199GLIB_AVAILABLE_IN_ALL
200void g_queue_delete_link (GQueue *queue,
201 GList *link_);
202
203G_END_DECLS
204
205#endif /* __G_QUEUE_H__ */
206