88 if (enumerator(self, node, element)) {
105 if (!predicate(node->element,
data)) {
121 for (
ListNode *node = self->
head; node; node = node->next) {
122 if (predicate(node->element,
data)) {
123 $(list,
append, node->element);
138 for (
ListNode *node = self->
head; node; node = node->next) {
139 if (predicate(node->element,
data)) {
140 return node->element;
165 if (node == NULL || node == self->
tail) {
174 newNode->
prev = node;
180 node->
next = newNode;
193 for (
ListNode *node = self->
head; node; node = node->next) {
194 node->element = functor(node->element,
data);
207 for (
ListNode *node = self->
head; node; node = node->next) {
208 $(list,
append, functor(node->element,
data));
220 for (
ListNode *node = self->
head; node; node = node->next) {
221 if (node->element == element) {
259 for (
ListNode *node = self->
head; node; node = node->next) {
260 accumulator = reducer(node->element, accumulator,
data);
334 if (self->
count < 2) {
348 (j ? j->
next : self->
head)->element = key;
353#pragma mark - Class lifecycle
393 .instanceSize =
sizeof(
List),
394 .interfaceOffset = offsetof(
List, interface),
395 .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 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 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.