1 //metadoc List copyright Steve Dekorte 2002
2 //metadoc List license BSD revised
3 /*metadoc List description
4 List - an array of void pointers
5 User is responsible for io_freeing items
20 #ifdef LOW_MEMORY_SYSTEM
21 #define LIST_START_SIZE 1
22 #define LIST_RESIZE_FACTOR 2
24 #define LIST_START_SIZE 1
25 #define LIST_RESIZE_FACTOR 2
28 #define LIST_AT_(self, n) self->items[n]
31 typedef void (ListDoCallback
)(void *);
32 typedef void (ListDoWithCallback
)(void *, void *);
33 typedef void *(ListCollectCallback
)(void *);
34 typedef int (ListSelectCallback
)(void *);
35 typedef int (ListDetectCallback
)(void *);
36 typedef int (ListSortCallback
)(const void *, const void *);
37 typedef int (ListCompareFunc
)(const void *, const void *);
52 BASEKIT_API List
*List_new(void);
53 BASEKIT_API List
*List_clone(const List
*self
);
54 BASEKIT_API List
*List_cloneSlice(const List
*self
, long startIndex
, long endIndex
);
56 BASEKIT_API
void List_free(List
*self
);
57 BASEKIT_API
void List_removeAll(List
*self
);
58 BASEKIT_API
void List_copy_(List
*self
, const List
*otherList
);
59 BASEKIT_API
int List_equals_(const List
*self
, const List
*otherList
);
60 BASEKIT_API
size_t List_memorySize(const List
*self
);
64 BASEKIT_API UArray
List_asStackAllocatedUArray(List
*self
);
68 BASEKIT_API
void List_preallocateToSize_(List
*self
, size_t index
);
69 BASEKIT_API
void List_setSize_(List
*self
, size_t index
);
70 BASEKIT_API
void List_compact(List
*self
);
74 BASEKIT_API
void List_print(const List
*self
);
75 BASEKIT_API
void List_sliceInPlace(List
*self
, long startIndex
, long endIndex
);
79 BASEKIT_API
void List_do_(List
*self
, ListDoCallback
*callback
);
80 BASEKIT_API
void List_do_with_(List
*self
, ListDoWithCallback
*callback
, void *arg
);
82 BASEKIT_API List
*List_map_(List
*self
, ListCollectCallback
*callback
);
83 BASEKIT_API
void List_mapInPlace_(List
*self
, ListCollectCallback
*callback
);
84 BASEKIT_API
void *List_detect_(List
*self
, ListDetectCallback
*callback
);
85 BASEKIT_API List
*List_select_(List
*self
, ListSelectCallback
*callback
);
87 BASEKIT_API
void *List_anyOne(const List
*self
);
88 BASEKIT_API
void List_shuffle(List
*self
);
89 BASEKIT_API
void *List_removeLast(List
*self
);
91 #include "List_inline.h"