00001 /* 00002 * $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ 00003 * 00004 * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. 00005 * Michael Clark <michael@metaparadigm.com> 00006 * 00007 * This library is free software; you can redistribute it and/or modify 00008 * it under the terms of the MIT license. See COPYING for details. 00009 * 00010 */ 00011 00012 #ifndef _arraylist_h_ 00013 #define _arraylist_h_ 00014 00015 #define ARRAY_LIST_DEFAULT_SIZE 32 00016 00017 typedef void (array_list_free_fn) (void *data); 00018 00019 struct array_list 00020 { 00021 void **array; 00022 int length; 00023 int size; 00024 array_list_free_fn *free_fn; 00025 }; 00026 00027 extern struct array_list* 00028 array_list_new(array_list_free_fn *free_fn); 00029 00030 extern void 00031 array_list_free(struct array_list *al); 00032 00033 extern void* 00034 array_list_get_idx(struct array_list *al, int i); 00035 00036 extern int 00037 array_list_put_idx(struct array_list *al, int i, void *data); 00038 00039 extern int 00040 array_list_add(struct array_list *al, void *data); 00041 00042 extern int 00043 array_list_length(struct array_list *al); 00044 00045 #endif