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 | |
36 | G_BEGIN_DECLS |
37 | |
38 | typedef 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 | */ |
49 | struct _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 | */ |
74 | GLIB_AVAILABLE_IN_ALL |
75 | GQueue* g_queue_new (void); |
76 | GLIB_AVAILABLE_IN_ALL |
77 | void g_queue_free (GQueue *queue); |
78 | GLIB_AVAILABLE_IN_ALL |
79 | void g_queue_free_full (GQueue *queue, |
80 | GDestroyNotify free_func); |
81 | GLIB_AVAILABLE_IN_ALL |
82 | void g_queue_init (GQueue *queue); |
83 | GLIB_AVAILABLE_IN_ALL |
84 | void g_queue_clear (GQueue *queue); |
85 | GLIB_AVAILABLE_IN_ALL |
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); |
90 | GLIB_AVAILABLE_IN_ALL |
91 | guint g_queue_get_length (GQueue *queue); |
92 | GLIB_AVAILABLE_IN_ALL |
93 | void g_queue_reverse (GQueue *queue); |
94 | GLIB_AVAILABLE_IN_ALL |
95 | GQueue * g_queue_copy (GQueue *queue); |
96 | GLIB_AVAILABLE_IN_ALL |
97 | void g_queue_foreach (GQueue *queue, |
98 | GFunc func, |
99 | gpointer user_data); |
100 | GLIB_AVAILABLE_IN_ALL |
101 | GList * g_queue_find (GQueue *queue, |
102 | gconstpointer data); |
103 | GLIB_AVAILABLE_IN_ALL |
104 | GList * g_queue_find_custom (GQueue *queue, |
105 | gconstpointer data, |
106 | GCompareFunc func); |
107 | GLIB_AVAILABLE_IN_ALL |
108 | void g_queue_sort (GQueue *queue, |
109 | GCompareDataFunc compare_func, |
110 | gpointer user_data); |
111 | |
112 | GLIB_AVAILABLE_IN_ALL |
113 | void g_queue_push_head (GQueue *queue, |
114 | gpointer data); |
115 | GLIB_AVAILABLE_IN_ALL |
116 | void g_queue_push_tail (GQueue *queue, |
117 | gpointer data); |
118 | GLIB_AVAILABLE_IN_ALL |
119 | void g_queue_push_nth (GQueue *queue, |
120 | gpointer data, |
121 | gint n); |
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, |
128 | guint n); |
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, |
135 | guint n); |
136 | GLIB_AVAILABLE_IN_ALL |
137 | gint g_queue_index (GQueue *queue, |
138 | gconstpointer data); |
139 | GLIB_AVAILABLE_IN_ALL |
140 | gboolean g_queue_remove (GQueue *queue, |
141 | gconstpointer data); |
142 | GLIB_AVAILABLE_IN_ALL |
143 | guint g_queue_remove_all (GQueue *queue, |
144 | gconstpointer data); |
145 | GLIB_AVAILABLE_IN_ALL |
146 | void g_queue_insert_before (GQueue *queue, |
147 | GList *sibling, |
148 | gpointer data); |
149 | GLIB_AVAILABLE_IN_2_62 |
150 | void g_queue_insert_before_link |
151 | (GQueue *queue, |
152 | GList *sibling, |
153 | GList *link_); |
154 | GLIB_AVAILABLE_IN_ALL |
155 | void g_queue_insert_after (GQueue *queue, |
156 | GList *sibling, |
157 | gpointer data); |
158 | GLIB_AVAILABLE_IN_2_62 |
159 | void g_queue_insert_after_link |
160 | (GQueue *queue, |
161 | GList *sibling, |
162 | GList *link_); |
163 | GLIB_AVAILABLE_IN_ALL |
164 | void g_queue_insert_sorted (GQueue *queue, |
165 | gpointer data, |
166 | GCompareDataFunc func, |
167 | gpointer user_data); |
168 | |
169 | GLIB_AVAILABLE_IN_ALL |
170 | void g_queue_push_head_link (GQueue *queue, |
171 | GList *link_); |
172 | GLIB_AVAILABLE_IN_ALL |
173 | void g_queue_push_tail_link (GQueue *queue, |
174 | GList *link_); |
175 | GLIB_AVAILABLE_IN_ALL |
176 | void g_queue_push_nth_link (GQueue *queue, |
177 | gint n, |
178 | GList *link_); |
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, |
185 | guint n); |
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, |
192 | guint n); |
193 | GLIB_AVAILABLE_IN_ALL |
194 | gint g_queue_link_index (GQueue *queue, |
195 | GList *link_); |
196 | GLIB_AVAILABLE_IN_ALL |
197 | void g_queue_unlink (GQueue *queue, |
198 | GList *link_); |
199 | GLIB_AVAILABLE_IN_ALL |
200 | void g_queue_delete_link (GQueue *queue, |
201 | GList *link_); |
202 | |
203 | G_END_DECLS |
204 | |
205 | #endif /* __G_QUEUE_H__ */ |
206 | |