Install json_object_private.h file
[platform/upstream/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 /**
13  * @file
14  * @brief Internal methods for working with json_type_array objects.
15  *        Although this is exposed by the json_object_get_array() method,
16  *        it is not recommended for direct use.
17  */
18 #ifndef _arraylist_h_
19 #define _arraylist_h_
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 #define ARRAY_LIST_DEFAULT_SIZE 32
26
27 typedef void (array_list_free_fn) (void *data);
28
29 struct array_list
30 {
31   void **array;
32   size_t length;
33   size_t size;
34   array_list_free_fn *free_fn;
35 };
36 typedef struct array_list array_list;
37
38 extern struct array_list*
39 array_list_new(array_list_free_fn *free_fn);
40
41 extern void
42 array_list_free(struct array_list *al);
43
44 extern void*
45 array_list_get_idx(struct array_list *al, size_t i);
46
47 extern int
48 array_list_put_idx(struct array_list *al, size_t i, void *data);
49
50 extern int
51 array_list_add(struct array_list *al, void *data);
52
53 extern size_t
54 array_list_length(struct array_list *al);
55
56 extern void
57 array_list_sort(struct array_list *arr, int(*compar)(const void *, const void *));
58
59 extern void* array_list_bsearch(const void **key,
60                 struct array_list *arr,
61                 int (*sort_fn)(const void *, const void *));
62
63 extern int 
64 array_list_del_idx(struct array_list *arr, size_t idx, size_t count);
65
66 #ifdef __cplusplus
67 }
68 #endif
69
70 #endif