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 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __G_SEQUENCE_H__
22#define __G_SEQUENCE_H__
23
24#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
25#error "Only <glib.h> can be included directly."
26#endif
27
28#include <glib/gtypes.h>
29
30G_BEGIN_DECLS
31
32typedef struct _GSequence GSequence;
33typedef struct _GSequenceNode GSequenceIter;
34
35typedef gint (* GSequenceIterCompareFunc) (GSequenceIter *a,
36 GSequenceIter *b,
37 gpointer data);
38
39
40/* GSequence */
41GLIB_AVAILABLE_IN_ALL
42GSequence * g_sequence_new (GDestroyNotify data_destroy);
43GLIB_AVAILABLE_IN_ALL
44void g_sequence_free (GSequence *seq);
45GLIB_AVAILABLE_IN_ALL
46gint g_sequence_get_length (GSequence *seq);
47GLIB_AVAILABLE_IN_ALL
48void g_sequence_foreach (GSequence *seq,
49 GFunc func,
50 gpointer user_data);
51GLIB_AVAILABLE_IN_ALL
52void g_sequence_foreach_range (GSequenceIter *begin,
53 GSequenceIter *end,
54 GFunc func,
55 gpointer user_data);
56GLIB_AVAILABLE_IN_ALL
57void g_sequence_sort (GSequence *seq,
58 GCompareDataFunc cmp_func,
59 gpointer cmp_data);
60GLIB_AVAILABLE_IN_ALL
61void g_sequence_sort_iter (GSequence *seq,
62 GSequenceIterCompareFunc cmp_func,
63 gpointer cmp_data);
64GLIB_AVAILABLE_IN_2_48
65gboolean g_sequence_is_empty (GSequence *seq);
66
67
68/* Getting iters */
69GLIB_AVAILABLE_IN_ALL
70GSequenceIter *g_sequence_get_begin_iter (GSequence *seq);
71GLIB_AVAILABLE_IN_ALL
72GSequenceIter *g_sequence_get_end_iter (GSequence *seq);
73GLIB_AVAILABLE_IN_ALL
74GSequenceIter *g_sequence_get_iter_at_pos (GSequence *seq,
75 gint pos);
76GLIB_AVAILABLE_IN_ALL
77GSequenceIter *g_sequence_append (GSequence *seq,
78 gpointer data);
79GLIB_AVAILABLE_IN_ALL
80GSequenceIter *g_sequence_prepend (GSequence *seq,
81 gpointer data);
82GLIB_AVAILABLE_IN_ALL
83GSequenceIter *g_sequence_insert_before (GSequenceIter *iter,
84 gpointer data);
85GLIB_AVAILABLE_IN_ALL
86void g_sequence_move (GSequenceIter *src,
87 GSequenceIter *dest);
88GLIB_AVAILABLE_IN_ALL
89void g_sequence_swap (GSequenceIter *a,
90 GSequenceIter *b);
91GLIB_AVAILABLE_IN_ALL
92GSequenceIter *g_sequence_insert_sorted (GSequence *seq,
93 gpointer data,
94 GCompareDataFunc cmp_func,
95 gpointer cmp_data);
96GLIB_AVAILABLE_IN_ALL
97GSequenceIter *g_sequence_insert_sorted_iter (GSequence *seq,
98 gpointer data,
99 GSequenceIterCompareFunc iter_cmp,
100 gpointer cmp_data);
101GLIB_AVAILABLE_IN_ALL
102void g_sequence_sort_changed (GSequenceIter *iter,
103 GCompareDataFunc cmp_func,
104 gpointer cmp_data);
105GLIB_AVAILABLE_IN_ALL
106void g_sequence_sort_changed_iter (GSequenceIter *iter,
107 GSequenceIterCompareFunc iter_cmp,
108 gpointer cmp_data);
109GLIB_AVAILABLE_IN_ALL
110void g_sequence_remove (GSequenceIter *iter);
111GLIB_AVAILABLE_IN_ALL
112void g_sequence_remove_range (GSequenceIter *begin,
113 GSequenceIter *end);
114GLIB_AVAILABLE_IN_ALL
115void g_sequence_move_range (GSequenceIter *dest,
116 GSequenceIter *begin,
117 GSequenceIter *end);
118GLIB_AVAILABLE_IN_ALL
119GSequenceIter *g_sequence_search (GSequence *seq,
120 gpointer data,
121 GCompareDataFunc cmp_func,
122 gpointer cmp_data);
123GLIB_AVAILABLE_IN_ALL
124GSequenceIter *g_sequence_search_iter (GSequence *seq,
125 gpointer data,
126 GSequenceIterCompareFunc iter_cmp,
127 gpointer cmp_data);
128GLIB_AVAILABLE_IN_ALL
129GSequenceIter *g_sequence_lookup (GSequence *seq,
130 gpointer data,
131 GCompareDataFunc cmp_func,
132 gpointer cmp_data);
133GLIB_AVAILABLE_IN_ALL
134GSequenceIter *g_sequence_lookup_iter (GSequence *seq,
135 gpointer data,
136 GSequenceIterCompareFunc iter_cmp,
137 gpointer cmp_data);
138
139
140/* Dereferencing */
141GLIB_AVAILABLE_IN_ALL
142gpointer g_sequence_get (GSequenceIter *iter);
143GLIB_AVAILABLE_IN_ALL
144void g_sequence_set (GSequenceIter *iter,
145 gpointer data);
146
147/* Operations on GSequenceIter * */
148GLIB_AVAILABLE_IN_ALL
149gboolean g_sequence_iter_is_begin (GSequenceIter *iter);
150GLIB_AVAILABLE_IN_ALL
151gboolean g_sequence_iter_is_end (GSequenceIter *iter);
152GLIB_AVAILABLE_IN_ALL
153GSequenceIter *g_sequence_iter_next (GSequenceIter *iter);
154GLIB_AVAILABLE_IN_ALL
155GSequenceIter *g_sequence_iter_prev (GSequenceIter *iter);
156GLIB_AVAILABLE_IN_ALL
157gint g_sequence_iter_get_position (GSequenceIter *iter);
158GLIB_AVAILABLE_IN_ALL
159GSequenceIter *g_sequence_iter_move (GSequenceIter *iter,
160 gint delta);
161GLIB_AVAILABLE_IN_ALL
162GSequence * g_sequence_iter_get_sequence (GSequenceIter *iter);
163
164
165/* Search */
166GLIB_AVAILABLE_IN_ALL
167gint g_sequence_iter_compare (GSequenceIter *a,
168 GSequenceIter *b);
169GLIB_AVAILABLE_IN_ALL
170GSequenceIter *g_sequence_range_get_midpoint (GSequenceIter *begin,
171 GSequenceIter *end);
172
173G_END_DECLS
174
175#endif /* __G_SEQUENCE_H__ */
176