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.1 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, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __G_SEQUENCE_H__
20#define __G_SEQUENCE_H__
21
22#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
23#error "Only <glib.h> can be included directly."
24#endif
25
26#include <glib/gtypes.h>
27
28G_BEGIN_DECLS
29
30typedef struct _GSequence GSequence;
31typedef struct _GSequenceNode GSequenceIter;
32
33typedef gint (* GSequenceIterCompareFunc) (GSequenceIter *a,
34 GSequenceIter *b,
35 gpointer data);
36
37
38/* GSequence */
39GLIB_AVAILABLE_IN_ALL
40GSequence * g_sequence_new (GDestroyNotify data_destroy);
41GLIB_AVAILABLE_IN_ALL
42void g_sequence_free (GSequence *seq);
43GLIB_AVAILABLE_IN_ALL
44gint g_sequence_get_length (GSequence *seq);
45GLIB_AVAILABLE_IN_ALL
46void g_sequence_foreach (GSequence *seq,
47 GFunc func,
48 gpointer user_data);
49GLIB_AVAILABLE_IN_ALL
50void g_sequence_foreach_range (GSequenceIter *begin,
51 GSequenceIter *end,
52 GFunc func,
53 gpointer user_data);
54GLIB_AVAILABLE_IN_ALL
55void g_sequence_sort (GSequence *seq,
56 GCompareDataFunc cmp_func,
57 gpointer cmp_data);
58GLIB_AVAILABLE_IN_ALL
59void g_sequence_sort_iter (GSequence *seq,
60 GSequenceIterCompareFunc cmp_func,
61 gpointer cmp_data);
62GLIB_AVAILABLE_IN_2_48
63gboolean g_sequence_is_empty (GSequence *seq);
64
65
66/* Getting iters */
67GLIB_AVAILABLE_IN_ALL
68GSequenceIter *g_sequence_get_begin_iter (GSequence *seq);
69GLIB_AVAILABLE_IN_ALL
70GSequenceIter *g_sequence_get_end_iter (GSequence *seq);
71GLIB_AVAILABLE_IN_ALL
72GSequenceIter *g_sequence_get_iter_at_pos (GSequence *seq,
73 gint pos);
74GLIB_AVAILABLE_IN_ALL
75GSequenceIter *g_sequence_append (GSequence *seq,
76 gpointer data);
77GLIB_AVAILABLE_IN_ALL
78GSequenceIter *g_sequence_prepend (GSequence *seq,
79 gpointer data);
80GLIB_AVAILABLE_IN_ALL
81GSequenceIter *g_sequence_insert_before (GSequenceIter *iter,
82 gpointer data);
83GLIB_AVAILABLE_IN_ALL
84void g_sequence_move (GSequenceIter *src,
85 GSequenceIter *dest);
86GLIB_AVAILABLE_IN_ALL
87void g_sequence_swap (GSequenceIter *a,
88 GSequenceIter *b);
89GLIB_AVAILABLE_IN_ALL
90GSequenceIter *g_sequence_insert_sorted (GSequence *seq,
91 gpointer data,
92 GCompareDataFunc cmp_func,
93 gpointer cmp_data);
94GLIB_AVAILABLE_IN_ALL
95GSequenceIter *g_sequence_insert_sorted_iter (GSequence *seq,
96 gpointer data,
97 GSequenceIterCompareFunc iter_cmp,
98 gpointer cmp_data);
99GLIB_AVAILABLE_IN_ALL
100void g_sequence_sort_changed (GSequenceIter *iter,
101 GCompareDataFunc cmp_func,
102 gpointer cmp_data);
103GLIB_AVAILABLE_IN_ALL
104void g_sequence_sort_changed_iter (GSequenceIter *iter,
105 GSequenceIterCompareFunc iter_cmp,
106 gpointer cmp_data);
107GLIB_AVAILABLE_IN_ALL
108void g_sequence_remove (GSequenceIter *iter);
109GLIB_AVAILABLE_IN_ALL
110void g_sequence_remove_range (GSequenceIter *begin,
111 GSequenceIter *end);
112GLIB_AVAILABLE_IN_ALL
113void g_sequence_move_range (GSequenceIter *dest,
114 GSequenceIter *begin,
115 GSequenceIter *end);
116GLIB_AVAILABLE_IN_ALL
117GSequenceIter *g_sequence_search (GSequence *seq,
118 gpointer data,
119 GCompareDataFunc cmp_func,
120 gpointer cmp_data);
121GLIB_AVAILABLE_IN_ALL
122GSequenceIter *g_sequence_search_iter (GSequence *seq,
123 gpointer data,
124 GSequenceIterCompareFunc iter_cmp,
125 gpointer cmp_data);
126GLIB_AVAILABLE_IN_ALL
127GSequenceIter *g_sequence_lookup (GSequence *seq,
128 gpointer data,
129 GCompareDataFunc cmp_func,
130 gpointer cmp_data);
131GLIB_AVAILABLE_IN_ALL
132GSequenceIter *g_sequence_lookup_iter (GSequence *seq,
133 gpointer data,
134 GSequenceIterCompareFunc iter_cmp,
135 gpointer cmp_data);
136
137
138/* Dereferencing */
139GLIB_AVAILABLE_IN_ALL
140gpointer g_sequence_get (GSequenceIter *iter);
141GLIB_AVAILABLE_IN_ALL
142void g_sequence_set (GSequenceIter *iter,
143 gpointer data);
144
145/* Operations on GSequenceIter * */
146GLIB_AVAILABLE_IN_ALL
147gboolean g_sequence_iter_is_begin (GSequenceIter *iter);
148GLIB_AVAILABLE_IN_ALL
149gboolean g_sequence_iter_is_end (GSequenceIter *iter);
150GLIB_AVAILABLE_IN_ALL
151GSequenceIter *g_sequence_iter_next (GSequenceIter *iter);
152GLIB_AVAILABLE_IN_ALL
153GSequenceIter *g_sequence_iter_prev (GSequenceIter *iter);
154GLIB_AVAILABLE_IN_ALL
155gint g_sequence_iter_get_position (GSequenceIter *iter);
156GLIB_AVAILABLE_IN_ALL
157GSequenceIter *g_sequence_iter_move (GSequenceIter *iter,
158 gint delta);
159GLIB_AVAILABLE_IN_ALL
160GSequence * g_sequence_iter_get_sequence (GSequenceIter *iter);
161
162
163/* Search */
164GLIB_AVAILABLE_IN_ALL
165gint g_sequence_iter_compare (GSequenceIter *a,
166 GSequenceIter *b);
167GLIB_AVAILABLE_IN_ALL
168GSequenceIter *g_sequence_range_get_midpoint (GSequenceIter *begin,
169 GSequenceIter *end);
170
171G_END_DECLS
172
173#endif /* __G_SEQUENCE_H__ */
174