Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
MutableArray.h
Go to the documentation of this file.
1/*
2 * Objectively: Ultra-lightweight object oriented framework for GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <Objectively/Array.h>
27
33typedef struct MutableArrayInterface MutableArrayInterface;
34
41
46
51 MutableArrayInterface *interface;
52
57 size_t capacity;
58};
59
63struct MutableArrayInterface {
64
68 ArrayInterface arrayInterface;
69
77 void (*addObject)(MutableArray *self, const ident obj);
78
86 void (*addObjects)(MutableArray *self, const ident obj, ...);
87
95 void (*addObjectsFromArray)(MutableArray *self, const Array *array);
96
104 MutableArray *(*array)(void);
105
114 MutableArray *(*arrayWithCapacity)(size_t capacity);
115
124 void (*filter)(MutableArray *self, Predicate predicate, ident data);
125
133 MutableArray *(*init)(MutableArray *self);
134
143 MutableArray *(*initWithCapacity)(MutableArray *self, size_t capacity);
144
153 void (*insertObjectAtIndex)(MutableArray *self, ident obj, size_t index);
154
161 void (*removeAllObjects)(MutableArray *self);
162
172
179 void (*removeLastObject)(MutableArray *self);
180
188 void (*removeObject)(MutableArray *self, const ident obj);
189
197 void (*removeObjectAtIndex)(MutableArray *self, size_t index);
198
208 void (*setObjectAtIndex)(MutableArray *self, const ident obj, size_t index);
209
217 void (*sort)(MutableArray *self, Comparator comparator);
218};
219
227
236OBJECTIVELY_EXPORT void quicksort(ident base, size_t count, size_t size, Comparator comparator, ident data);
Immutable arrays.
void(* ArrayEnumerator)(const Array *array, ident obj, ident data)
A function pointer for Array enumeration (iteration).
Definition: Array.h:49
#define obj
static void removeObject(MutableArray *self, const ident obj)
Definition: MutableArray.c:270
static void sort(MutableArray *self, Comparator comparator)
Definition: MutableArray.c:314
static void insertObjectAtIndex(MutableArray *self, ident obj, size_t index)
Definition: MutableArray.c:215
static void removeAllObjectsWithEnumerator(MutableArray *self, ArrayEnumerator enumerator, ident data)
Definition: MutableArray.c:243
static void removeAllObjects(MutableArray *self)
Definition: MutableArray.c:232
static void removeLastObject(MutableArray *self)
Definition: MutableArray.c:259
static void addObjects(MutableArray *self, const ident obj,...)
Definition: MutableArray.c:122
static void removeObjectAtIndex(MutableArray *self, size_t index)
Definition: MutableArray.c:282
static void setObjectAtIndex(MutableArray *self, const ident obj, size_t index)
Definition: MutableArray.c:299
static MutableArray * array(void)
Definition: MutableArray.c:153
static void filter(MutableArray *self, Predicate predicate, ident data)
Definition: MutableArray.c:171
static void addObjectsFromArray(MutableArray *self, const Array *array)
Definition: MutableArray.c:140
static void addObject(MutableArray *self, const ident obj)
Definition: MutableArray.c:99
OBJECTIVELY_EXPORT void quicksort(ident base, size_t count, size_t size, Comparator comparator, ident data)
A portability wrapper around reentrant qsort.
Definition: MutableArray.c:67
static MutableData * data(void)
Definition: MutableData.c:75
void * ident
The identity type, similar to Objective-C id.
Definition: Types.h:49
#define OBJECTIVELY_EXPORT
Definition: Types.h:36
_Bool(* Predicate)(const ident obj, ident data)
The Predicate function type for filtering Objects.
Definition: Types.h:111
Order(* Comparator)(const ident obj1, const ident obj2)
The Comparator function type for ordering Objects.
Definition: Types.h:82
Immutable arrays.
Definition: Array.h:56
The runtime representation of a Class.
Definition: Class.h:95
Mutable arrays.
Definition: MutableArray.h:40
Array array
The superclass.
Definition: MutableArray.h:45
MutableArrayInterface * interface
The interface.
Definition: MutableArray.h:51
Class * _MutableArray(void)
The MutableArray archetype.
Definition: MutableArray.c:349
MutableData * data(void)
Returns a new MutableData.
Definition: MutableData.c:75