5 * Duncan Mak (duncan@novell.com)
6 * Gonzalo Paniagua Javier (gonzalo@novell.com)
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Copyright (c) 2006-2009 Novell, Inc.
35 g_queue_pop_head (GQueue *queue)
40 if (!queue || queue->length == 0)
43 result = queue->head->data;
44 old_head = queue->head;
45 queue->head = old_head->next;
46 g_list_free_1 (old_head);
49 queue->head->prev = NULL;
57 g_queue_is_empty (GQueue *queue)
62 return queue->length == 0;
66 g_queue_push_head (GQueue *queue, gpointer head)
71 queue->head = g_list_prepend (queue->head, head);
74 queue->tail = queue->head;
80 g_queue_push_tail (GQueue *queue, gpointer data)
85 queue->tail = g_list_append (queue->tail, data);
86 if (queue->head == NULL)
87 queue->head = queue->tail;
89 queue->tail = queue->tail->next;
96 return g_new0 (GQueue, 1);
100 g_queue_free (GQueue *queue)
105 g_list_free (queue->head);
110 g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data)
112 g_list_foreach (queue->head, func, user_data);