Added a changelog entry.
[profile/ivi/json-c.git] / arraylist.h
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
16 extern "C" {
17 #endif
18
19 #define ARRAY_LIST_DEFAULT_SIZE 32
20
21 typedef void (array_list_free_fn) (void *data);
22
23 struct array_list
24 {
25   void **array;
26   int length;
27   int size;
28   array_list_free_fn *free_fn;
29 };
30
31 extern struct array_list*
32 array_list_new(array_list_free_fn *free_fn);
33
34 extern void
35 array_list_free(struct array_list *al);
36
37 extern void*
38 array_list_get_idx(struct array_list *al, int i);
39
40 extern int
41 array_list_put_idx(struct array_list *al, int i, void *data);
42
43 extern int
44 array_list_add(struct array_list *al, void *data);
45
46 extern int
47 array_list_length(struct array_list *al);
48
49 extern void
50 array_list_sort(struct array_list *arr, int(*compar)(const void *, const void *));
51
52 #ifdef __cplusplus
53 }
54 #endif
55
56 #endif