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