migrate per-thread magazine caches from single-thread scenario to first
[platform/upstream/glib.git] / glib / gsequence.h
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
3  * Soeren Sandmann (sandmann@daimi.au.dk)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include <glib/gtypes.h>
22
23 #ifndef __G_SEQUENCE_H__
24 #define __G_SEQUENCE_H__
25
26 typedef struct _GSequence      GSequence;
27 typedef struct _GSequenceNode  GSequenceIter;
28
29 typedef gint (* GSequenceIterCompareFunc) (GSequenceIter *a,
30                                            GSequenceIter *b,
31                                            gpointer       data);
32
33
34 /* GSequence */
35 GSequence *    g_sequence_new                (GDestroyNotify            data_destroy);
36 void           g_sequence_free               (GSequence                *seq);
37 gint           g_sequence_get_length         (GSequence                *seq);
38 void           g_sequence_foreach            (GSequence                *seq,
39                                               GFunc                     func,
40                                               gpointer                  user_data);
41 void           g_sequence_foreach_range      (GSequenceIter            *begin,
42                                               GSequenceIter            *end,
43                                               GFunc                     func,
44                                               gpointer                  user_data);
45 void           g_sequence_sort               (GSequence                *seq,
46                                               GCompareDataFunc          cmp_func,
47                                               gpointer                  cmp_data);
48 void           g_sequence_sort_iter          (GSequence                *seq,
49                                               GSequenceIterCompareFunc  cmp_func,
50                                               gpointer                  cmp_data);
51
52
53 /* Getting iters */
54 GSequenceIter *g_sequence_get_begin_iter     (GSequence                *seq);
55 GSequenceIter *g_sequence_get_end_iter       (GSequence                *seq);
56 GSequenceIter *g_sequence_get_iter_at_pos    (GSequence                *seq,
57                                               gint                      pos);
58 GSequenceIter *g_sequence_append             (GSequence                *seq,
59                                               gpointer                  data);
60 GSequenceIter *g_sequence_prepend            (GSequence                *seq,
61                                               gpointer                  data);
62 GSequenceIter *g_sequence_insert_before      (GSequenceIter            *iter,
63                                               gpointer                  data);
64 void           g_sequence_move               (GSequenceIter            *src,
65                                               GSequenceIter            *dest);
66 void           g_sequence_swap               (GSequenceIter            *a,
67                                               GSequenceIter            *b);
68 GSequenceIter *g_sequence_insert_sorted      (GSequence                *seq,
69                                               gpointer                  data,
70                                               GCompareDataFunc          cmp_func,
71                                               gpointer                  cmp_data);
72 GSequenceIter *g_sequence_insert_sorted_iter (GSequence                *seq,
73                                               gpointer                  data,
74                                               GSequenceIterCompareFunc  iter_cmp,
75                                               gpointer                  cmp_data);
76 void           g_sequence_sort_changed       (GSequenceIter            *iter,
77                                               GCompareDataFunc          cmp_func,
78                                               gpointer                  cmp_data);
79 void           g_sequence_sort_changed_iter  (GSequenceIter            *iter,
80                                               GSequenceIterCompareFunc  iter_cmp,
81                                               gpointer                  cmp_data);
82 void           g_sequence_remove             (GSequenceIter            *iter);
83 void           g_sequence_remove_range       (GSequenceIter            *begin,
84                                               GSequenceIter            *end);
85 void           g_sequence_move_range         (GSequenceIter            *dest,
86                                               GSequenceIter            *begin,
87                                               GSequenceIter            *end);
88 GSequenceIter *g_sequence_search             (GSequence                *seq,
89                                               gpointer                  data,
90                                               GCompareDataFunc          cmp_func,
91                                               gpointer                  cmp_data);
92 GSequenceIter *g_sequence_search_iter        (GSequence                *seq,
93                                               gpointer                  data,
94                                               GSequenceIterCompareFunc  iter_cmp,
95                                               gpointer                  cmp_data);
96
97
98 /* Dereferencing */
99 gpointer       g_sequence_get                (GSequenceIter            *iter);
100 void           g_sequence_set                (GSequenceIter            *iter,
101                                               gpointer                  data);
102
103 /* Operations on GSequenceIter * */
104 gboolean       g_sequence_iter_is_begin      (GSequenceIter            *iter);
105 gboolean       g_sequence_iter_is_end        (GSequenceIter            *iter);
106 GSequenceIter *g_sequence_iter_next          (GSequenceIter            *iter);
107 GSequenceIter *g_sequence_iter_prev          (GSequenceIter            *iter);
108 gint           g_sequence_iter_get_position  (GSequenceIter            *iter);
109 GSequenceIter *g_sequence_iter_move          (GSequenceIter            *iter,
110                                               gint                      delta);
111 GSequence *    g_sequence_iter_get_sequence  (GSequenceIter            *iter);
112
113
114 /* Search */
115 gint           g_sequence_iter_compare       (GSequenceIter            *a,
116                                               GSequenceIter            *b);
117 GSequenceIter *g_sequence_range_get_midpoint (GSequenceIter            *begin,
118                                               GSequenceIter            *end);
119
120
121 #endif /* __G_SEQUENCE_H__ */