00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __G_ARRAY_H__
00029 #define __G_ARRAY_H__
00030
00031 #include <_ansi.h>
00032 #include <glib/gtypes.h>
00033
00034 G_BEGIN_DECLS
00035
00036 typedef struct _GArray GArray;
00037 typedef struct _GByteArray GByteArray;
00038 typedef struct _GPtrArray GPtrArray;
00039
00040 struct _GArray
00041 {
00042 gchar *data;
00043 guint len;
00044 };
00045
00046 struct _GByteArray
00047 {
00048 guint8 *data;
00049 guint len;
00050 };
00051
00052 struct _GPtrArray
00053 {
00054 gpointer *pdata;
00055 guint len;
00056 };
00057
00058
00059
00060
00061
00062
00063 #define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1)
00064 #define g_array_prepend_val(a,v) g_array_prepend_vals (a, &(v), 1)
00065 #define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1)
00066 #define g_array_index(a,t,i) (((t*) (a)->data) [(i)])
00067
00068 IMPORT_C GArray* g_array_new (gboolean zero_terminated,
00069 gboolean clear_,
00070 guint element_size);
00071 IMPORT_C GArray* g_array_sized_new (gboolean zero_terminated,
00072 gboolean clear_,
00073 guint element_size,
00074 guint reserved_size);
00075 IMPORT_C gchar* g_array_free (GArray *array,
00076 gboolean free_segment);
00077 IMPORT_C GArray* g_array_append_vals (GArray *array,
00078 gconstpointer data,
00079 guint len);
00080 IMPORT_C GArray* g_array_prepend_vals (GArray *array,
00081 gconstpointer data,
00082 guint len);
00083 IMPORT_C GArray* g_array_insert_vals (GArray *array,
00084 guint index_,
00085 gconstpointer data,
00086 guint len);
00087 IMPORT_C GArray* g_array_set_size (GArray *array,
00088 guint length);
00089 IMPORT_C GArray* g_array_remove_index (GArray *array,
00090 guint index_);
00091 IMPORT_C GArray* g_array_remove_index_fast (GArray *array,
00092 guint index_);
00093 IMPORT_C GArray* g_array_remove_range (GArray *array,
00094 guint index_,
00095 guint length);
00096 IMPORT_C void g_array_sort (GArray *array,
00097 GCompareFunc compare_func);
00098 IMPORT_C void g_array_sort_with_data (GArray *array,
00099 GCompareDataFunc compare_func,
00100 gpointer user_data);
00101
00102
00103
00104
00105
00106 #define g_ptr_array_index(array,index_) ((array)->pdata)[index_]
00107 IMPORT_C GPtrArray* g_ptr_array_new (void);
00108 IMPORT_C GPtrArray* g_ptr_array_sized_new (guint reserved_size);
00109 IMPORT_C gpointer* g_ptr_array_free (GPtrArray *array,
00110 gboolean free_seg);
00111 IMPORT_C void g_ptr_array_set_size (GPtrArray *array,
00112 gint length);
00113 IMPORT_C gpointer g_ptr_array_remove_index (GPtrArray *array,
00114 guint index_);
00115 IMPORT_C gpointer g_ptr_array_remove_index_fast (GPtrArray *array,
00116 guint index_);
00117 IMPORT_C gboolean g_ptr_array_remove (GPtrArray *array,
00118 gpointer data);
00119 IMPORT_C gboolean g_ptr_array_remove_fast (GPtrArray *array,
00120 gpointer data);
00121 IMPORT_C void g_ptr_array_remove_range (GPtrArray *array,
00122 guint index_,
00123 guint length);
00124 IMPORT_C void g_ptr_array_add (GPtrArray *array,
00125 gpointer data);
00126 IMPORT_C void g_ptr_array_sort (GPtrArray *array,
00127 GCompareFunc compare_func);
00128 IMPORT_C void g_ptr_array_sort_with_data (GPtrArray *array,
00129 GCompareDataFunc compare_func,
00130 gpointer user_data);
00131 IMPORT_C void g_ptr_array_foreach (GPtrArray *array,
00132 GFunc func,
00133 gpointer user_data);
00134
00135
00136
00137
00138
00139
00140 IMPORT_C GByteArray* g_byte_array_new (void);
00141 IMPORT_C GByteArray* g_byte_array_sized_new (guint reserved_size);
00142 IMPORT_C guint8* g_byte_array_free (GByteArray *array,
00143 gboolean free_segment);
00144 IMPORT_C GByteArray* g_byte_array_append (GByteArray *array,
00145 const guint8 *data,
00146 guint len);
00147 IMPORT_C GByteArray* g_byte_array_prepend (GByteArray *array,
00148 const guint8 *data,
00149 guint len);
00150 IMPORT_C GByteArray* g_byte_array_set_size (GByteArray *array,
00151 guint length);
00152 IMPORT_C GByteArray* g_byte_array_remove_index (GByteArray *array,
00153 guint index_);
00154 IMPORT_C GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
00155 guint index_);
00156 IMPORT_C GByteArray* g_byte_array_remove_range (GByteArray *array,
00157 guint index_,
00158 guint length);
00159 IMPORT_C void g_byte_array_sort (GByteArray *array,
00160 GCompareFunc compare_func);
00161 IMPORT_C void g_byte_array_sort_with_data (GByteArray *array,
00162 GCompareDataFunc compare_func,
00163 gpointer user_data);
00164
00165
00166 G_END_DECLS
00167
00168 #endif
00169