1 | /* |
---|
2 | * This file Copyright (C) 2007-2008 Charles Kerr <charles@rebelbase.com> |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2(b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id: ptrarray.h 4876 2008-01-31 02:24:43Z charles $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef _TR_POINTERS_H_ |
---|
14 | #define _TR_POINTERS_H_ |
---|
15 | |
---|
16 | /** |
---|
17 | * A simple pointer array that resizes itself dynamically. |
---|
18 | */ |
---|
19 | typedef struct tr_ptrArray tr_ptrArray; |
---|
20 | |
---|
21 | typedef void (*PtrArrayForeachFunc)(void *); |
---|
22 | |
---|
23 | tr_ptrArray * tr_ptrArrayNew ( void ); |
---|
24 | tr_ptrArray * tr_ptrArrayDup ( tr_ptrArray* ); |
---|
25 | void tr_ptrArrayForeach ( tr_ptrArray*, PtrArrayForeachFunc func ); |
---|
26 | void tr_ptrArrayFree ( tr_ptrArray*, PtrArrayForeachFunc func ); |
---|
27 | void* tr_ptrArrayNth ( tr_ptrArray*, int n ); |
---|
28 | void* tr_ptrArrayBack ( tr_ptrArray* ); |
---|
29 | void** tr_ptrArrayPeek ( tr_ptrArray*, int * size ); |
---|
30 | void** tr_ptrArrayBase ( tr_ptrArray* ); |
---|
31 | void tr_ptrArrayClear ( tr_ptrArray* ); |
---|
32 | int tr_ptrArrayInsert ( tr_ptrArray*, void*, int pos ); |
---|
33 | int tr_ptrArrayAppend ( tr_ptrArray*, void* ); |
---|
34 | void* tr_ptrArrayPop ( tr_ptrArray* ); |
---|
35 | void tr_ptrArrayErase ( tr_ptrArray*, int begin, int end ); |
---|
36 | int tr_ptrArraySize ( const tr_ptrArray* ); |
---|
37 | int tr_ptrArrayEmpty ( const tr_ptrArray* ); |
---|
38 | int tr_ptrArrayInsertSorted ( tr_ptrArray*, void*, |
---|
39 | int compare(const void*,const void*) ); |
---|
40 | void* tr_ptrArrayRemoveSorted ( tr_ptrArray*, void*, |
---|
41 | int compare(const void*,const void*) ); |
---|
42 | void* tr_ptrArrayFindSorted ( tr_ptrArray*, const void*, |
---|
43 | int compare(const void*,const void*) ); |
---|
44 | |
---|
45 | #endif |
---|