|
Objectively
Ultra-lightweight object oriented framework for GNU C.
|
#include <PointerArray.h>
Growable arrays of raw C pointers.
Like Vector, but specialized for pointer-sized elements. The destroy callback receives the stored pointer value itself (i.e. elements[i]), not a pointer into the backing buffer.
Definition at line 44 of file PointerArray.h.
Properties | |
| size_t | capacity |
| The capacity. | |
| size_t | count |
| The count of elements. | |
| Consumer | destroy |
| Optional destructor called when a element is removed. | |
| ident * | elements |
| The backing array of pointers. | |
| Object | object |
| The superclass. | |
Properties inherited from Object | |
| Class * | clazz |
| Every instance of Object begins with a pointer to its Class. | |
| unsigned int | magic |
| A header to allow introspection of Object types. | |
Methods | |
| Class * | _PointerArray (void) |
| The PointerArray archetype. | |
| void | add (PointerArray *self, ident pointer) |
| Appends the given pointer to this PointerArray. | |
| ident | get (const PointerArray *self, size_t index) |
| PointerArray * | init (PointerArray *self) |
| Initializes this PointerArray. | |
| PointerArray * | initWithDestroy (PointerArray *self, Consumer destroy) |
| Initializes this PointerArray with a destructor. | |
| void | remove (PointerArray *self, ident pointer) |
Removes the first occurrence of pointer from this PointerArray. | |
| void | removeAll (PointerArray *self) |
| Removes all elements from this PointerArray without modifying its capacity. | |
| void | removeAt (PointerArray *self, size_t index) |
| Removes the pointer at the specified index. | |
| void | sort (PointerArray *self, Comparator comparator) |
Sorts this PointerArray in place using comparator. | |
Methods inherited from Object | |
| Class * | _Object (void) |
| The Object archetype. | |
| Object * | copy (const Object *self) |
| Creates a shallow copy of this Object. | |
| void | dealloc (Object *self) |
| Frees all resources held by this Object. | |
| String * | description (const Object *self) |
| int | hash (const Object *self) |
| Object * | init (Object *self) |
| Initializes this Object. | |
| bool | isEqual (const Object *self, const Object *other) |
| Tests equality of the other Object. | |
| bool | isKindOfClass (const Object *self, const Class *clazz) |
| Tests for Class hierarchy membership. | |
Protected Attributes | |
| PointerArrayInterface * | interface |
| The interface. | |
Protected Attributes inherited from Object | |
| ObjectInterface * | interface |
| The interface. | |
| size_t PointerArray::capacity |
The capacity.
Definition at line 60 of file PointerArray.h.
| size_t PointerArray::count |
The count of elements.
Definition at line 65 of file PointerArray.h.
| Consumer PointerArray::destroy |
Optional destructor called when a element is removed.
The argument is the pointer value itself, not a pointer into the backing buffer.
Definition at line 72 of file PointerArray.h.
| ident* PointerArray::elements |
The backing array of pointers.
Definition at line 77 of file PointerArray.h.
|
protected |
The interface.
Definition at line 55 of file PointerArray.h.
| Object PointerArray::object |
The superclass.
Definition at line 49 of file PointerArray.h.
| Class * _PointerArray | ( | void | ) |
The PointerArray archetype.
Definition at line 181 of file PointerArray.c.
| void add | ( | PointerArray * | self, |
| ident | pointer | ||
| ) |
Appends the given pointer to this PointerArray.
| self | The PointerArray. |
| pointer | The pointer to add. |
Definition at line 57 of file PointerArray.c.
| ident get | ( | const PointerArray * | self, |
| size_t | index | ||
| ) |
| self | The PointerArray. |
| index | The index. |
Definition at line 74 of file PointerArray.c.
| PointerArray * init | ( | PointerArray * | self | ) |
Initializes this PointerArray.
| self | The PointerArray. |
NULL on error. Definition at line 85 of file PointerArray.c.
| PointerArray * initWithDestroy | ( | PointerArray * | self, |
| Consumer | destroy | ||
| ) |
Initializes this PointerArray with a destructor.
| self | The PointerArray. |
| destroy | An optional destructor called when a pointer is removed, or NULL. |
NULL on error. Definition at line 93 of file PointerArray.c.
| void remove | ( | PointerArray * | self, |
| ident | pointer | ||
| ) |
Removes the first occurrence of pointer from this PointerArray.
| self | The PointerArray. |
| pointer | The element to remove (compared by value). |
| void removeAll | ( | PointerArray * | self | ) |
Removes all elements from this PointerArray without modifying its capacity.
| self | The PointerArray. |
Definition at line 121 of file PointerArray.c.
| void removeAt | ( | PointerArray * | self, |
| size_t | index | ||
| ) |
Removes the pointer at the specified index.
| self | The PointerArray. |
| index | The index of the element to remove. |
Definition at line 136 of file PointerArray.c.
| void sort | ( | PointerArray * | self, |
| Comparator | comparator | ||
| ) |
Sorts this PointerArray in place using comparator.
| self | The PointerArray. |
| comparator | A Comparator. |
Definition at line 154 of file PointerArray.c.