1/* 2 * $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ 3 * 4 * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. 5 * Michael Clark <michael@metaparadigm.com> 6 * 7 * This library is free software; you can redistribute it and/or modify 8 * it under the terms of the MIT license. See COPYING for details. 9 * 10 */ 11 12#ifndef _arraylist_h_ 13#define _arraylist_h_ 14 15#ifdef __cplusplus 16extern "C" { 17#endif 18 19#define ARRAY_LIST_DEFAULT_SIZE 32 20 21typedef void (array_list_free_fn) (void *data); 22 23struct array_list 24{ 25 void **array; 26 int length; 27 int size; 28 array_list_free_fn *free_fn; 29}; 30 31extern struct array_list* 32array_list_new(array_list_free_fn *free_fn); 33 34extern void 35array_list_free(struct array_list *al); 36 37extern void* 38array_list_get_idx(struct array_list *al, int i); 39 40extern int 41array_list_put_idx(struct array_list *al, int i, void *data); 42 43extern int 44array_list_add(struct array_list *al, void *data); 45 46extern int 47array_list_length(struct array_list *al); 48 49extern void 50array_list_sort(struct array_list *arr, int(*compar)(const void *, const void *)); 51 52#ifdef __cplusplus 53} 54#endif 55 56#endif 57