/* GLIB - Library of useful routines for C programming * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * Modified by the GLib Team and others 1997-2000. See the AUTHORS * file for a list of people on the GLib Team. See the ChangeLog * files for a list of changes. These files are distributed with * GLib at ftp://ftp.gtk.org/pub/gtk/. */ #ifndef __MW_ARRAY_H__ #define __MW_ARRAY_H__ MW_BEGIN_DECLS #include typedef struct _mw_array mw_array_t; typedef struct _mw_array_type mw_array_type_t; struct _mw_array { mw_object_t base; mw_char_t *data; mw_uint_t len; mw_uint_t alloc; mw_uint_t elt_size; mw_uint_t zero_terminated : 1; mw_uint_t clear : 1; }; struct _mw_array_type { mw_object_type_t base; }; /* Resizable arrays. remove fills any cleared spot and shortens the * array, while preserving the order. remove_fast will distort the * order by moving the last element to the position of the removed. */ #define mw_array_append_val(a,v) mw_array_append_vals (a, &(v), 1) #define mw_array_prepend_val(a,v) mw_array_prepend_vals (a, &(v), 1) #define mw_array_insert_val(a,i,v) mw_array_insert_vals (a, i, &(v), 1) #define mw_array_index(a,t,i) (((t*) (void *) (a)->data) [(i)]) #define MW_ARRAY_TYPE mw_array_get_type() mw_public mw_array_type_t* mw_array_get_type(void); mw_public mw_array_t* mw_array_new (mw_bool_t zero_terminated, mw_bool_t clear_, mw_uint_t element_size); mw_public mw_array_t* mw_array_sized_new (mw_bool_t zero_terminated, mw_bool_t clear_, mw_uint_t element_size, mw_uint_t reserved_size); mw_public char* mw_array_take (mw_array_t *array); mw_public mw_uint_t mw_array_get_element_size (mw_array_t *array); mw_public mw_array_t* mw_array_append_vals (mw_array_t *array, const mw_pointer_t data, mw_uint_t len); mw_public mw_array_t* mw_array_prepend_vals (mw_array_t *array, const mw_pointer_t data, mw_uint_t len); mw_public mw_array_t* mw_array_insert_vals (mw_array_t *array, mw_uint_t index_, const mw_pointer_t data, mw_uint_t len); mw_public mw_array_t* mw_array_set_size (mw_array_t *array, mw_uint_t length); mw_public mw_array_t* mw_array_remove_index (mw_array_t *array, mw_uint_t index_); mw_public mw_array_t* mw_array_remove_index_fast (mw_array_t *array, mw_uint_t index_); mw_public mw_array_t* mw_array_remove_range (mw_array_t *array, mw_uint_t index_, mw_uint_t length); mw_public void mw_array_sort (mw_array_t *array, mw_compare_func_t compare_func); mw_public void mw_array_sort_with_data (mw_array_t *array, mw_compare_data_func_t compare_func, mw_pointer_t user_data); MW_END_DECLS #endif /* __MW_ARRAY_H__ */