Move single-include guards inside include guards
[platform/upstream/glib.git] / glib / glist.h
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
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_LIST_H__
28 #define __G_LIST_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/gmem.h>
35 #include <glib/gnode.h>
36
37 G_BEGIN_DECLS
38
39 typedef struct _GList GList;
40
41 struct _GList
42 {
43   gpointer data;
44   GList *next;
45   GList *prev;
46 };
47
48 /* Doubly linked lists
49  */
50 GList*   g_list_alloc                   (void) G_GNUC_WARN_UNUSED_RESULT;
51 void     g_list_free                    (GList            *list);
52 void     g_list_free_1                  (GList            *list);
53 #define  g_list_free1                   g_list_free_1
54 void     g_list_free_full               (GList            *list,
55                                          GDestroyNotify    free_func);
56 GList*   g_list_append                  (GList            *list,
57                                          gpointer          data) G_GNUC_WARN_UNUSED_RESULT;
58 GList*   g_list_prepend                 (GList            *list,
59                                          gpointer          data) G_GNUC_WARN_UNUSED_RESULT;
60 GList*   g_list_insert                  (GList            *list,
61                                          gpointer          data,
62                                          gint              position) G_GNUC_WARN_UNUSED_RESULT;
63 GList*   g_list_insert_sorted           (GList            *list,
64                                          gpointer          data,
65                                          GCompareFunc      func) G_GNUC_WARN_UNUSED_RESULT;
66 GList*   g_list_insert_sorted_with_data (GList            *list,
67                                          gpointer          data,
68                                          GCompareDataFunc  func,
69                                          gpointer          user_data) G_GNUC_WARN_UNUSED_RESULT;
70 GList*   g_list_insert_before           (GList            *list,
71                                          GList            *sibling,
72                                          gpointer          data) G_GNUC_WARN_UNUSED_RESULT;
73 GList*   g_list_concat                  (GList            *list1,
74                                          GList            *list2) G_GNUC_WARN_UNUSED_RESULT;
75 GList*   g_list_remove                  (GList            *list,
76                                          gconstpointer     data) G_GNUC_WARN_UNUSED_RESULT;
77 GList*   g_list_remove_all              (GList            *list,
78                                          gconstpointer     data) G_GNUC_WARN_UNUSED_RESULT;
79 GList*   g_list_remove_link             (GList            *list,
80                                          GList            *llink) G_GNUC_WARN_UNUSED_RESULT;
81 GList*   g_list_delete_link             (GList            *list,
82                                          GList            *link_) G_GNUC_WARN_UNUSED_RESULT;
83 GList*   g_list_reverse                 (GList            *list) G_GNUC_WARN_UNUSED_RESULT;
84 GList*   g_list_copy                    (GList            *list) G_GNUC_WARN_UNUSED_RESULT;
85
86 GLIB_AVAILABLE_IN_2_34
87 GList*   g_list_copy_deep               (GList            *list,
88                                          GCopyFunc         func,
89                                          gpointer          user_data) G_GNUC_WARN_UNUSED_RESULT;
90
91 GList*   g_list_nth                     (GList            *list,
92                                          guint             n);
93 GList*   g_list_nth_prev                (GList            *list,
94                                          guint             n);
95 GList*   g_list_find                    (GList            *list,
96                                          gconstpointer     data);
97 GList*   g_list_find_custom             (GList            *list,
98                                          gconstpointer     data,
99                                          GCompareFunc      func);
100 gint     g_list_position                (GList            *list,
101                                          GList            *llink);
102 gint     g_list_index                   (GList            *list,
103                                          gconstpointer     data);
104 GList*   g_list_last                    (GList            *list);
105 GList*   g_list_first                   (GList            *list);
106 guint    g_list_length                  (GList            *list);
107 void     g_list_foreach                 (GList            *list,
108                                          GFunc             func,
109                                          gpointer          user_data);
110 GList*   g_list_sort                    (GList            *list,
111                                          GCompareFunc      compare_func) G_GNUC_WARN_UNUSED_RESULT;
112 GList*   g_list_sort_with_data          (GList            *list,
113                                          GCompareDataFunc  compare_func,
114                                          gpointer          user_data)  G_GNUC_WARN_UNUSED_RESULT;
115 gpointer g_list_nth_data                (GList            *list,
116                                          guint             n);
117
118
119 #define g_list_previous(list)           ((list) ? (((GList *)(list))->prev) : NULL)
120 #define g_list_next(list)               ((list) ? (((GList *)(list))->next) : NULL)
121
122 G_END_DECLS
123
124 #endif /* __G_LIST_H__ */