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