xref: /Universal-ctags/main/ptrarray.h (revision e460488f00fcd2a1ae16ca014e25843045fd7ea1)
1 /*
2 *   Copyright (c) 1999-2002, Darren Hiebert
3 *
4 *   This source code is released for free distribution under the terms of the
5 *   GNU General Public License version 2 or (at your option) any later version.
6 *
7 *   Defines external interface to resizable pointer arrays.
8 */
9 #ifndef CTAGS_MAIN_PTRARRAY_H
10 #define CTAGS_MAIN_PTRARRAY_H
11 
12 /*
13 *   INCLUDE FILES
14 */
15 #include "general.h"  /* must always come first */
16 #include "types.h"
17 
18 /*
19 *   DATA DECLARATIONS
20 */
21 struct sPtrArray;
22 typedef struct sPtrArray ptrArray;
23 
24 typedef void (*ptrArrayDeleteFunc) (void *data);
25 
26 
27 /*
28 *   FUNCTION PROTOTYPES
29 */
30 
31 extern ptrArray *ptrArrayNew (ptrArrayDeleteFunc deleteFunc);
32 extern unsigned int ptrArrayAdd (ptrArray *const current, void *ptr);
33 extern bool ptrArrayUpdate (ptrArray *const current, unsigned int indx, void *ptr, void *padding);
34 extern void *ptrArrayRemoveLast (ptrArray *const current);
35 #define ptrArrayDeleteLast(A) ptrArrayDeleteLastInBatch(A, 1)
36 extern void  ptrArrayDeleteLastInBatch (ptrArray *const current, unsigned int count);
37 extern void ptrArrayCombine (ptrArray *const current, ptrArray *const from);
38 extern void ptrArrayClear (ptrArray *const current);
39 extern unsigned int ptrArrayCount (const ptrArray *const current);
40 #define ptrArrayIsEmpty(A) (ptrArrayCount(A) == 0)
41 extern void* ptrArrayItem (const ptrArray *const current, const unsigned int indx);
42 extern void* ptrArrayItemFromLast (const ptrArray *const current, const unsigned int indx);
43 #define ptrArrayLast(A) ptrArrayItemFromLast(A, 0)
44 extern void ptrArrayDelete (ptrArray *const current);
45 extern bool ptrArrayHasTest (const ptrArray *const current,
46 				  bool (*test)(const void *ptr, void *userData),
47 				  void *userData);
48 extern bool ptrArrayHas (const ptrArray *const current, void *ptr);
49 extern void ptrArrayReverse (const ptrArray *const current);
50 extern void ptrArrayDeleteItem (ptrArray* const current, unsigned int indx);
51 extern void*ptrArrayRemoveItem (ptrArray* const current, unsigned int indx);
52 extern void ptrArrayInsertItem (ptrArray* const current, unsigned int indx, void *ptr);
53 
54 extern void ptrArraySort (ptrArray *const current, int (*compare)(const void *, const void *));
55 
56 #endif  /* CTAGS_MAIN_PTRARRAY_H */
57