29#define _Class _MutableIndexSet
31#define INDEX_SET_CHUNK_SIZE 8
45#pragma mark - MutableIndexSet
56 for (i = 0; i < this->count; i++) {
57 if (this->indexes[i] == index) {
60 if (this->indexes[i] > index) {
68 this->indexes = realloc(this->indexes, self->
capacity *
sizeof(
size_t));
69 assert(this->indexes);
72 for (
size_t j = this->count; j > i; j--) {
73 this->indexes[j] = this->indexes[j - 1];
76 this->indexes[i] = index;
86 for (
size_t i = 0; i < count; i++) {
125 this->indexes = malloc(self->
capacity *
sizeof(
size_t));
126 assert(this->indexes);
141 this->indexes = NULL;
154 for (
size_t i = 0; i < this->count; i++) {
155 if (this->indexes[i] == index) {
157 for (
size_t j = i; j < this->count; j++) {
158 this->indexes[j] = this->indexes[j + 1];
171 for (
size_t i = 0; i < count; i++) {
187#pragma mark - Class lifecycle
199 ((MutableIndexSetInterface *) clazz->
interface)->init =
init;
217 .name =
"MutableIndexSet",
221 .interfaceSize =
sizeof(MutableIndexSetInterface),
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define super(type, obj, method,...)
static void initialize(Class *clazz)
#define INDEX_SET_CHUNK_SIZE
Mutable collections of unique index values.
#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.
Condition * init(Condition *self)
Initializes this Condition.
Immutable collections of unique index values.
Class * _IndexSet(void)
The IndexSet archetype.
MutableArray * initWithCapacity(MutableArray *self, size_t capacity)
Initializes this MutableArray with the specified capacity.
Mutable collections of unique index values.
void addIndexes(MutableIndexSet *self, size_t *indexes, size_t count)
Adds the specified indexes to this MutableIndexSet.
void removeIndexesInRange(MutableIndexSet *self, const Range range)
Removes indexes in the specified Range from this MutableIndexSet.
void addIndex(MutableIndexSet *self, size_t index)
Adds the specified index to this MutableIndexSet.
void removeIndex(MutableIndexSet *self, size_t index)
Removes the specified index from this MutableIndexSet.
void removeIndexes(MutableIndexSet *self, size_t *indexes, size_t count)
Removes the specified indexes from this MutableIndexSet.
void addIndexesInRange(MutableIndexSet *self, const Range range)
Adds indexes in the specified Range to this MutableIndexSet.
size_t capacity
The capacity.
Class * _MutableIndexSet(void)
The MutableIndexSet archetype.
IndexSet indexSet
The superclass.
void removeAllIndexes(MutableIndexSet *self)
Removes all indexes from this MutableIndexSet.
Object is the root Class of The Objectively Class hierarchy.
void dealloc(Object *self)
Frees all resources held by this Object.
A location and length into contiguous collections.
ssize_t location
The location.