glist.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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_LIST_H__
  24. #define __G_LIST_H__
  25. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #include <glib/gmem.h>
  29. #include <glib/gnode.h>
  30. G_BEGIN_DECLS
  31. typedef struct _GList GList;
  32. struct _GList
  33. {
  34. gpointer data;
  35. GList *next;
  36. GList *prev;
  37. };
  38. /* Doubly linked lists
  39. */
  40. GLIB_AVAILABLE_IN_ALL
  41. GList* g_list_alloc (void) G_GNUC_WARN_UNUSED_RESULT;
  42. GLIB_AVAILABLE_IN_ALL
  43. void g_list_free (GList *list);
  44. GLIB_AVAILABLE_IN_ALL
  45. void g_list_free_1 (GList *list);
  46. #define g_list_free1 g_list_free_1
  47. GLIB_AVAILABLE_IN_ALL
  48. void g_list_free_full (GList *list,
  49. GDestroyNotify free_func);
  50. GLIB_AVAILABLE_IN_ALL
  51. GList* g_list_append (GList *list,
  52. gpointer data) G_GNUC_WARN_UNUSED_RESULT;
  53. GLIB_AVAILABLE_IN_ALL
  54. GList* g_list_prepend (GList *list,
  55. gpointer data) G_GNUC_WARN_UNUSED_RESULT;
  56. GLIB_AVAILABLE_IN_ALL
  57. GList* g_list_insert (GList *list,
  58. gpointer data,
  59. gint position) G_GNUC_WARN_UNUSED_RESULT;
  60. GLIB_AVAILABLE_IN_ALL
  61. GList* g_list_insert_sorted (GList *list,
  62. gpointer data,
  63. GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT;
  64. GLIB_AVAILABLE_IN_ALL
  65. GList* g_list_insert_sorted_with_data (GList *list,
  66. gpointer data,
  67. GCompareDataFunc func,
  68. gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
  69. GLIB_AVAILABLE_IN_ALL
  70. GList* g_list_insert_before (GList *list,
  71. GList *sibling,
  72. gpointer data) G_GNUC_WARN_UNUSED_RESULT;
  73. GLIB_AVAILABLE_IN_ALL
  74. GList* g_list_concat (GList *list1,
  75. GList *list2) G_GNUC_WARN_UNUSED_RESULT;
  76. GLIB_AVAILABLE_IN_ALL
  77. GList* g_list_remove (GList *list,
  78. gconstpointer data) G_GNUC_WARN_UNUSED_RESULT;
  79. GLIB_AVAILABLE_IN_ALL
  80. GList* g_list_remove_all (GList *list,
  81. gconstpointer data) G_GNUC_WARN_UNUSED_RESULT;
  82. GLIB_AVAILABLE_IN_ALL
  83. GList* g_list_remove_link (GList *list,
  84. GList *llink) G_GNUC_WARN_UNUSED_RESULT;
  85. GLIB_AVAILABLE_IN_ALL
  86. GList* g_list_delete_link (GList *list,
  87. GList *link_) G_GNUC_WARN_UNUSED_RESULT;
  88. GLIB_AVAILABLE_IN_ALL
  89. GList* g_list_reverse (GList *list) G_GNUC_WARN_UNUSED_RESULT;
  90. GLIB_AVAILABLE_IN_ALL
  91. GList* g_list_copy (GList *list) G_GNUC_WARN_UNUSED_RESULT;
  92. GLIB_AVAILABLE_IN_2_34
  93. GList* g_list_copy_deep (GList *list,
  94. GCopyFunc func,
  95. gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
  96. GLIB_AVAILABLE_IN_ALL
  97. GList* g_list_nth (GList *list,
  98. guint n);
  99. GLIB_AVAILABLE_IN_ALL
  100. GList* g_list_nth_prev (GList *list,
  101. guint n);
  102. GLIB_AVAILABLE_IN_ALL
  103. GList* g_list_find (GList *list,
  104. gconstpointer data);
  105. GLIB_AVAILABLE_IN_ALL
  106. GList* g_list_find_custom (GList *list,
  107. gconstpointer data,
  108. GCompareFunc func);
  109. GLIB_AVAILABLE_IN_ALL
  110. gint g_list_position (GList *list,
  111. GList *llink);
  112. GLIB_AVAILABLE_IN_ALL
  113. gint g_list_index (GList *list,
  114. gconstpointer data);
  115. GLIB_AVAILABLE_IN_ALL
  116. GList* g_list_last (GList *list);
  117. GLIB_AVAILABLE_IN_ALL
  118. GList* g_list_first (GList *list);
  119. GLIB_AVAILABLE_IN_ALL
  120. guint g_list_length (GList *list);
  121. GLIB_AVAILABLE_IN_ALL
  122. void g_list_foreach (GList *list,
  123. GFunc func,
  124. gpointer user_data);
  125. GLIB_AVAILABLE_IN_ALL
  126. GList* g_list_sort (GList *list,
  127. GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT;
  128. GLIB_AVAILABLE_IN_ALL
  129. GList* g_list_sort_with_data (GList *list,
  130. GCompareDataFunc compare_func,
  131. gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
  132. GLIB_AVAILABLE_IN_ALL
  133. gpointer g_list_nth_data (GList *list,
  134. guint n);
  135. #define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL)
  136. #define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL)
  137. G_END_DECLS
  138. #endif /* __G_LIST_H__ */