1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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.
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/.
30 #include <glib/gtypes.h>
34 typedef struct _GArray GArray;
35 typedef struct _GByteArray GByteArray;
36 typedef struct _GPtrArray GPtrArray;
56 /* Resizable arrays, remove fills any cleared spot and shortens the
57 * array, while preserving the order. remove_fast will distort the
58 * order by moving the last element to the position of the removed
61 #define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1)
62 #define g_array_prepend_val(a,v) g_array_prepend_vals (a, &(v), 1)
63 #define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1)
64 #define g_array_index(a,t,i) (((t*) (a)->data) [(i)])
66 GArray* g_array_new (gboolean zero_terminated,
69 GArray* g_array_sized_new (gboolean zero_terminated,
73 gchar* g_array_free (GArray *array,
74 gboolean free_segment);
75 GArray* g_array_append_vals (GArray *array,
78 GArray* g_array_prepend_vals (GArray *array,
81 GArray* g_array_insert_vals (GArray *array,
85 GArray* g_array_set_size (GArray *array,
87 GArray* g_array_remove_index (GArray *array,
89 GArray* g_array_remove_index_fast (GArray *array,
91 void g_array_sort (GArray *array,
92 GCompareFunc compare_func);
93 void g_array_sort_with_data (GArray *array,
94 GCompareDataFunc compare_func,
97 /* Resizable pointer array. This interface is much less complicated
98 * than the above. Add appends appends a pointer. Remove fills any
99 * cleared spot and shortens the array. remove_fast will again distort
102 #define g_ptr_array_index(array,index) ((array)->pdata)[index]
103 GPtrArray* g_ptr_array_new (void);
104 GPtrArray* g_ptr_array_sized_new (guint reserved_size);
105 gpointer* g_ptr_array_free (GPtrArray *array,
107 void g_ptr_array_set_size (GPtrArray *array,
109 gpointer g_ptr_array_remove_index (GPtrArray *array,
111 gpointer g_ptr_array_remove_index_fast (GPtrArray *array,
113 gboolean g_ptr_array_remove (GPtrArray *array,
115 gboolean g_ptr_array_remove_fast (GPtrArray *array,
117 void g_ptr_array_add (GPtrArray *array,
119 void g_ptr_array_sort (GPtrArray *array,
120 GCompareFunc compare_func);
121 void g_ptr_array_sort_with_data (GPtrArray *array,
122 GCompareDataFunc compare_func,
126 /* Byte arrays, an array of guint8. Implemented as a GArray,
130 GByteArray* g_byte_array_new (void);
131 GByteArray* g_byte_array_sized_new (guint reserved_size);
132 guint8* g_byte_array_free (GByteArray *array,
133 gboolean free_segment);
134 GByteArray* g_byte_array_append (GByteArray *array,
137 GByteArray* g_byte_array_prepend (GByteArray *array,
140 GByteArray* g_byte_array_set_size (GByteArray *array,
142 GByteArray* g_byte_array_remove_index (GByteArray *array,
144 GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
146 void g_byte_array_sort (GByteArray *array,
147 GCompareFunc compare_func);
148 void g_byte_array_sort_with_data (GByteArray *array,
149 GCompareDataFunc compare_func,
155 #endif /* __G_ARRAY_H__ */