gqueue.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 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. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  19. * file for a list of people on the GLib Team. See the ChangeLog
  20. * files for a list of changes. These files are distributed with
  21. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  22. */
  23. #ifndef __G_QUEUE_H__
  24. #define __G_QUEUE_H__
  25. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #include <glib/glist.h>
  29. G_BEGIN_DECLS
  30. typedef struct _GQueue GQueue;
  31. /**
  32. * GQueue:
  33. * @head: a pointer to the first element of the queue
  34. * @tail: a pointer to the last element of the queue
  35. * @length: the number of elements in the queue
  36. *
  37. * Contains the public fields of a
  38. * <link linkend="glib-Double-ended-Queues">Queue</link>.
  39. */
  40. struct _GQueue
  41. {
  42. GList *head;
  43. GList *tail;
  44. guint length;
  45. };
  46. /**
  47. * G_QUEUE_INIT:
  48. *
  49. * A statically-allocated #GQueue must be initialized with this
  50. * macro before it can be used. This macro can be used to initialize
  51. * a variable, but it cannot be assigned to a variable. In that case
  52. * you have to use g_queue_init().
  53. *
  54. * |[
  55. * GQueue my_queue = G_QUEUE_INIT;
  56. * ]|
  57. *
  58. * Since: 2.14
  59. */
  60. #define G_QUEUE_INIT { NULL, NULL, 0 }
  61. /* Queues
  62. */
  63. GLIB_AVAILABLE_IN_ALL
  64. GQueue* g_queue_new (void);
  65. GLIB_AVAILABLE_IN_ALL
  66. void g_queue_free (GQueue *queue);
  67. GLIB_AVAILABLE_IN_ALL
  68. void g_queue_free_full (GQueue *queue,
  69. GDestroyNotify free_func);
  70. GLIB_AVAILABLE_IN_ALL
  71. void g_queue_init (GQueue *queue);
  72. GLIB_AVAILABLE_IN_ALL
  73. void g_queue_clear (GQueue *queue);
  74. GLIB_AVAILABLE_IN_ALL
  75. gboolean g_queue_is_empty (GQueue *queue);
  76. GLIB_AVAILABLE_IN_ALL
  77. guint g_queue_get_length (GQueue *queue);
  78. GLIB_AVAILABLE_IN_ALL
  79. void g_queue_reverse (GQueue *queue);
  80. GLIB_AVAILABLE_IN_ALL
  81. GQueue * g_queue_copy (GQueue *queue);
  82. GLIB_AVAILABLE_IN_ALL
  83. void g_queue_foreach (GQueue *queue,
  84. GFunc func,
  85. gpointer user_data);
  86. GLIB_AVAILABLE_IN_ALL
  87. GList * g_queue_find (GQueue *queue,
  88. gconstpointer data);
  89. GLIB_AVAILABLE_IN_ALL
  90. GList * g_queue_find_custom (GQueue *queue,
  91. gconstpointer data,
  92. GCompareFunc func);
  93. GLIB_AVAILABLE_IN_ALL
  94. void g_queue_sort (GQueue *queue,
  95. GCompareDataFunc compare_func,
  96. gpointer user_data);
  97. GLIB_AVAILABLE_IN_ALL
  98. void g_queue_push_head (GQueue *queue,
  99. gpointer data);
  100. GLIB_AVAILABLE_IN_ALL
  101. void g_queue_push_tail (GQueue *queue,
  102. gpointer data);
  103. GLIB_AVAILABLE_IN_ALL
  104. void g_queue_push_nth (GQueue *queue,
  105. gpointer data,
  106. gint n);
  107. GLIB_AVAILABLE_IN_ALL
  108. gpointer g_queue_pop_head (GQueue *queue);
  109. GLIB_AVAILABLE_IN_ALL
  110. gpointer g_queue_pop_tail (GQueue *queue);
  111. GLIB_AVAILABLE_IN_ALL
  112. gpointer g_queue_pop_nth (GQueue *queue,
  113. guint n);
  114. GLIB_AVAILABLE_IN_ALL
  115. gpointer g_queue_peek_head (GQueue *queue);
  116. GLIB_AVAILABLE_IN_ALL
  117. gpointer g_queue_peek_tail (GQueue *queue);
  118. GLIB_AVAILABLE_IN_ALL
  119. gpointer g_queue_peek_nth (GQueue *queue,
  120. guint n);
  121. GLIB_AVAILABLE_IN_ALL
  122. gint g_queue_index (GQueue *queue,
  123. gconstpointer data);
  124. GLIB_AVAILABLE_IN_ALL
  125. gboolean g_queue_remove (GQueue *queue,
  126. gconstpointer data);
  127. GLIB_AVAILABLE_IN_ALL
  128. guint g_queue_remove_all (GQueue *queue,
  129. gconstpointer data);
  130. GLIB_AVAILABLE_IN_ALL
  131. void g_queue_insert_before (GQueue *queue,
  132. GList *sibling,
  133. gpointer data);
  134. GLIB_AVAILABLE_IN_ALL
  135. void g_queue_insert_after (GQueue *queue,
  136. GList *sibling,
  137. gpointer data);
  138. GLIB_AVAILABLE_IN_ALL
  139. void g_queue_insert_sorted (GQueue *queue,
  140. gpointer data,
  141. GCompareDataFunc func,
  142. gpointer user_data);
  143. GLIB_AVAILABLE_IN_ALL
  144. void g_queue_push_head_link (GQueue *queue,
  145. GList *link_);
  146. GLIB_AVAILABLE_IN_ALL
  147. void g_queue_push_tail_link (GQueue *queue,
  148. GList *link_);
  149. GLIB_AVAILABLE_IN_ALL
  150. void g_queue_push_nth_link (GQueue *queue,
  151. gint n,
  152. GList *link_);
  153. GLIB_AVAILABLE_IN_ALL
  154. GList* g_queue_pop_head_link (GQueue *queue);
  155. GLIB_AVAILABLE_IN_ALL
  156. GList* g_queue_pop_tail_link (GQueue *queue);
  157. GLIB_AVAILABLE_IN_ALL
  158. GList* g_queue_pop_nth_link (GQueue *queue,
  159. guint n);
  160. GLIB_AVAILABLE_IN_ALL
  161. GList* g_queue_peek_head_link (GQueue *queue);
  162. GLIB_AVAILABLE_IN_ALL
  163. GList* g_queue_peek_tail_link (GQueue *queue);
  164. GLIB_AVAILABLE_IN_ALL
  165. GList* g_queue_peek_nth_link (GQueue *queue,
  166. guint n);
  167. GLIB_AVAILABLE_IN_ALL
  168. gint g_queue_link_index (GQueue *queue,
  169. GList *link_);
  170. GLIB_AVAILABLE_IN_ALL
  171. void g_queue_unlink (GQueue *queue,
  172. GList *link_);
  173. GLIB_AVAILABLE_IN_ALL
  174. void g_queue_delete_link (GQueue *queue,
  175. GList *link_);
  176. G_END_DECLS
  177. #endif /* __G_QUEUE_H__ */