31#define _Class _PointerArray
33#define POINTER_ARRAY_CHUNK_SIZE 64
51#pragma mark - PointerArray
76 assert(index < self->count);
109 for (
size_t i = 0; i < self->
count; i++) {
124 for (
size_t i = 0; i < self->
count; i++) {
138 assert(index < self->count);
144 const size_t tail = self->
count - index - 1;
158#pragma mark - Class lifecycle
167 ((PointerArrayInterface *) clazz->
interface)->add =
add;
168 ((PointerArrayInterface *) clazz->
interface)->get =
get;
187 .name =
"PointerArray",
191 .interfaceSize =
sizeof(PointerArrayInterface),
void quicksort(ident base, size_t count, size_t size, Comparator comparator, ident data)
A portability wrapper around reentrant qsort.
static void destroy(Class *clazz)
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define super(type, obj, method,...)
static void removeAll(PointerArray *self)
static void add(PointerArray *self, ident pointer)
static ident get(const PointerArray *self, size_t index)
static PointerArray * initWithDestroy(PointerArray *self, Consumer destroy)
static void removeAt(PointerArray *self, size_t index)
static PointerArray * init(PointerArray *self)
static void sort(PointerArray *self, Comparator comparator)
static void dealloc(Object *self)
static void _remove(PointerArray *self, ident pointer)
#define POINTER_ARRAY_CHUNK_SIZE
static void initialize(Class *clazz)
Class * _PointerArray(void)
Growable arrays of raw C pointers.
void * ident
The identity type, similar to Objective-C id.
Order(* Comparator)(const ident obj1, const ident obj2)
The Comparator function type for ordering Objects.
void(* Consumer)(ident data)
The Consumer function type.
#define do_once(once, block)
Executes the given block at most one time.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
ident interface
The interface of the Class.
Object is the root Class of The Objectively Class hierarchy.
Growable arrays of raw C pointers.
ident * elements
The backing array of pointers.
PointerArray * initWithDestroy(PointerArray *self, Consumer destroy)
Initializes this PointerArray with a destructor.
Consumer destroy
Optional destructor called when a element is removed.
size_t count
The count of elements.
size_t capacity
The capacity.
void remove(PointerArray *self, ident pointer)
Removes the first occurrence of pointer from this PointerArray.