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