33#define _Class _MutableDictionary
35#define MUTABLEDICTIONARY_DEFAULT_CAPACITY 64
36#define MUTABLEDICTIONARY_GROW_FACTOR 2.0
37#define MUTABLEDICTIONARY_MAX_LOAD 0.75f
55#pragma mark - MutableDictionary
128 for (
size_t i = 0; i < self->
dictionary.capacity; i++) {
147 for (
size_t i = 0; i < self->
dictionary.capacity; i++) {
151 for (
size_t j =
array->
count; j > 0; j -= 2) {
218 if (dict->capacity) {
220 const float load = dict->
count / (float) dict->capacity;
223 size_t capacity = dict->capacity;
224 ident *elements = dict->elements;
229 dict->elements = calloc(dict->capacity,
sizeof(
ident));
230 assert(dict->elements);
232 for (
size_t i = 0; i < capacity; i++) {
237 for (
size_t j = 0; j <
array->
count; j += 2) {
304 va_start(args, self);
310 const char *path = va_arg(args,
const char *);
327 va_start(args, self);
343#pragma mark - Class lifecycle
377 .name =
"MutableDictionary",
381 .interfaceSize =
sizeof(MutableDictionaryInterface),
ident release(ident obj)
Atomically decrement the given Object's reference count. If the resulting reference count is 0,...
Class * _initialize(const ClassDef *def)
Initializes the given Class.
#define alloc(type)
Allocate and initialize and instance of type.
#define super(type, obj, method,...)
void(* DictionaryEnumerator)(const Dictionary *dictionary, ident obj, ident key, ident data)
A function type for Dictionary enumeration (iteration).
int HashForObject(int hash, const ident obj)
Accumulates the hash value of object into hash.
Utilities for calculating hash values.
#define HASH_SEED
The hash seed value.
static void addEntriesFromDictionary_enumerator(const Dictionary *dict, ident obj, ident key, ident data)
DictionaryEnumerator for addEntriesFromDictionary.
#define MUTABLEDICTIONARY_DEFAULT_CAPACITY
#define MUTABLEDICTIONARY_MAX_LOAD
static void setObjectForKey_resize(Dictionary *dict)
A helper for resizing Dictionaries as pairs are added to them.
#define MUTABLEDICTIONARY_GROW_FACTOR
static void initialize(Class *clazz)
Mutable key-value stores.
void * ident
The identity type, similar to Objective-C id.
#define do_once(once, block)
Executes the given block at most one time.
ssize_t indexOfObject(const Array *self, const ident obj)
ident objectAtIndex(const Array *self, int index)
size_t count
The count of elements.
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 key-value stores.
Class * _Dictionary(void)
The Dictionary archetype.
size_t count
The count of elements.
void enumerateObjectsAndKeys(const Dictionary *self, DictionaryEnumerator enumerator, ident data)
Enumerate the pairs of this Dictionary with the given function.
void removeAllObjectsWithEnumerator(MutableArray *self, ArrayEnumerator enumerator, ident data)
Removes all Objects from this MutableArray, invoking enumerator for each Object.
void removeObjectAtIndex(MutableArray *self, size_t index)
Removes the Object at the specified index.
void setObjectAtIndex(MutableArray *self, const ident obj, size_t index)
Replaces the Object at the specified index.
MutableArray * arrayWithCapacity(size_t capacity)
Returns a new MutableArray with the given capacity.
void addObject(MutableArray *self, const ident obj)
Adds the specified Object to this MutableArray.
void removeAllObjects(MutableArray *self)
Removes all Objects from this MutableArray.
MutableArray * array(void)
Returns a new MutableArray.
MutableArray * initWithCapacity(MutableArray *self, size_t capacity)
Initializes this MutableArray with the specified capacity.
MutableData * data(void)
Returns a new MutableData.
Mutable key-value stores.
MutableDictionary * dictionaryWithCapacity(size_t capacity)
Returns a new MutableDictionary with the given capacity.
void removeObjectForKeyPath(MutableDictionary *self, const char *path)
Removes the Object with the specified key path from this MutableDictionary.
void setObjectForKeyPath(MutableDictionary *self, const ident obj, const char *path)
Sets a pair in this MutableDictionary.
void setObjectsForKeys(MutableDictionary *self,...)
Sets pairs in this MutableDictionary from the NULL-terminated list.
Dictionary dictionary
The superclass.
void removeObjectForKey(MutableDictionary *self, const ident key)
Removes the Object with the specified key from this MutableDictionary.
MutableDictionary * init(MutableDictionary *self)
Initializes this MutableDictionary.
void setObjectForKey(MutableDictionary *self, const ident obj, const ident key)
Sets a pair in this MutableDictionary.
Class * _MutableDictionary(void)
The MutableDictionary archetype.
void setObjectsForKeyPaths(MutableDictionary *self,...)
Sets pairs in this MutableDictionary from the NULL-terminated list.
MutableDictionary * dictionary(void)
Returns a new MutableDictionary.
void addEntriesFromDictionary(MutableDictionary *self, const Dictionary *dictionary)
Adds the key-value entries from dictionary to this MutableDictionary.
Object is the root Class of The Objectively Class hierarchy.
Object * copy(const Object *self)
Creates a shallow copy of this Object.
String * stringWithCharacters(const char *chars)
Returns a new String by copying chars.