108 if (enumerator(self, node, element)) {
125 if (!predicate(node->element,
data)) {
141 for (
ListNode *node = self->
head; node; node = node->next) {
142 if (predicate(node->element,
data)) {
143 $(list,
append, node->element);
158 for (
ListNode *node = self->
head; node; node = node->next) {
159 if (predicate(node->element,
data)) {
160 return node->element;
185 if (node == NULL || node == self->
tail) {
194 newNode->
prev = node;
200 node->
next = newNode;
213 for (
ListNode *node = self->
head; node; node = node->next) {
214 node->element = functor(node->element,
data);
227 for (
ListNode *node = self->
head; node; node = node->next) {
228 $(list,
append, functor(node->element,
data));
240 for (
ListNode *node = self->
head; node; node = node->next) {
241 if (node->element == element) {
279 for (
ListNode *node = self->
head; node; node = node->next) {
280 accumulator = reducer(node->element, accumulator,
data);
354 if (self->
count < 2) {
368 (j ? j->
next : self->
head)->element = key;
373#pragma mark - Class lifecycle
414 .instanceSize =
sizeof(
List),
415 .interfaceSize =
sizeof(ListInterface),
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define alloc(type)
Allocate and initialize and instance of type.
#define super(type, obj, method,...)
static void prepend(List *self, const ident element)
static bool contains(const List *self, const ident element)
static List * init(List *self)
static ident find(const List *self, Predicate predicate, ident data)
static void _remove(List *self, const ident element)
static List * mappedList(const List *self, Functor functor, ident data)
static void removeAll(List *self)
static void insertAfter(List *self, ListNode *node, const ident element)
static void removeNode(List *self, ListNode *node)
static void map(List *self, Functor functor, ident data)
static void filter(List *self, Predicate predicate, ident data)
static void _sort(List *self, Comparator comparator)
static void dealloc(Object *self)
static ListNode * nodeForElement(const List *self, const ident element)
static void append(List *self, const ident element)
static ident reduce(const List *self, Reducer reducer, ident accumulator, ident data)
static void enumerate(const List *self, ListEnumerator enumerator, ident element)
static Object * copy(const Object *self)
static void initialize(Class *clazz)
static List * filteredList(const List *self, Predicate predicate, ident data)
Doubly-linked lists of raw C pointers.
bool(* ListEnumerator)(const List *list, ListNode *node, ident data)
The ListEnumerator function type.
static int head(RESTClient *self, const char *url, const char **headers)
static Unicode next(StringReader *self, StringReaderMode mode)
void * ident
The identity type, similar to Objective-C id.
bool(* Predicate)(const ident obj, ident data)
The Predicate function type for filtering Objects.
Order(* Comparator)(const ident obj1, const ident obj2)
The Comparator function type for ordering Objects.
ident(* Functor)(const ident obj, ident data)
The Functor function type for transforming Objects.
ident(* Reducer)(const ident obj, ident accumulator, ident data)
The Reducer function type for reducing collections.
#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.
Doubly-linked lists of raw C pointers.
ident find(const List *self, Predicate predicate, ident data)
ListNode * head
The head node.
size_t count
The number of elements.
Consumer destroy
Optional destructor called when an element is removed.
ListNode * tail
The tail node.
ListNode * nodeForElement(const List *self, const ident element)
void insertAfter(List *self, ListNode *node, const ident element)
Inserts an element after the given node.
Object is the root Class of The Objectively Class hierarchy.
void dealloc(Object *self)
Frees all resources held by this Object.