34#define _Class _Dictionary
57 for (
size_t i = 0; i < this->capacity; i++) {
109 for (
size_t i = 0; i < this->capacity; i++) {
110 if (this->elements[i]) {
132 if (this->count == that->
count) {
136 for (
size_t i = 0; i < keys->
count; i++) {
142 if ($(thisObject,
isEqual, thatObject) ==
false) {
156#pragma mark - Dictionary
175 return (
Array *) keys;
195 return (
Array *) objects;
258 for (
size_t i = 0; i < self->capacity; i++) {
263 for (
size_t j = 0; j <
array->
count; j += 2) {
268 enumerator(self,
obj, key,
data);
284 for (
size_t i = 0; i < self->capacity; i++) {
289 for (
size_t j = 0; j <
array->
count; j += 2) {
294 if (predicate(
obj, key,
data)) {
316 self->elements = calloc(self->capacity,
sizeof(
ident));
317 assert(self->elements);
319 for (
size_t i = 0; i <
dictionary->capacity; i++) {
344 va_start(args, self);
384 if (self->capacity == 0) {
394 if (index > -1 && (index & 1) == 0) {
419#pragma mark - Class lifecycle
457 .name =
"Dictionary",
460 .interfaceOffset = offsetof(
Dictionary, interface),
461 .interfaceSize =
sizeof(DictionaryInterface),
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,...)
static void description_enumerator(const Dictionary *dict, ident obj, ident key, ident data)
A DictionaryEnumerator for description.
static void allKeys_enumerator(const Dictionary *dict, ident obj, ident key, ident data)
DictionaryEnumerator for allKeys.
static void allObjects_enumerator(const Dictionary *dict, ident obj, ident key, ident data)
DictionaryEnumerator for allObjects.
static void initialize(Class *clazz)
Immutable key-value stores.
void(* DictionaryEnumerator)(const Dictionary *dictionary, ident obj, ident key, ident data)
A function type for Dictionary enumeration (iteration).
_Bool(* DictionaryPredicate)(ident obj, ident key, ident data)
A function pointer for Dictionary filtering.
int HashForInteger(int hash, const long integer)
Accumulates the hash value of integer into hash.
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.
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.
MutableArray * mutableCopy(const Array *self)
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.
MutableDictionary * mutableCopy(const Dictionary *self)
Class * _Dictionary(void)
The Dictionary archetype.
Array * allObjects(const Dictionary *self)
Dictionary * dictionaryWithObjectsAndKeys(ident obj,...)
Returns a new Dictionary containing pairs from the given arguments.
Dictionary * initWithDictionary(Dictionary *self, const Dictionary *dictionary)
Initializes this Dictionary to contain elements of dictionary.
ident objectForKeyPath(const Dictionary *self, const char *path)
Dicionary * filterObjectsAndKeys(const Dictionary *self, DictionaryPredicate predicate, ident data)
Creates a new Dictionary with pairs that pass the filter function.
size_t count
The count of elements.
Array * allKeys(const Dictionary *self)
_Bool containsKeyPath(const Dictionary *self, const char *path)
_Bool containsKey(const Dictionary *self, const ident key)
Dictionary * dictionaryWithDictionary(const Dictionary *dictionary)
Returns a new Dictionary containing all pairs from dictionary.
ident objectForKey(const Dictionary *self, const ident key)
Dictionary * initWithObjectsAndKeys(Dictionary *self,...)
Initializes this Dictionary with the NULL-terminated list of Objects and keys.
void enumerateObjectsAndKeys(const Dictionary *self, DictionaryEnumerator enumerator, ident data)
Enumerate the pairs of this Dictionary with the given function.
void addObject(MutableArray *self, const ident obj)
Adds the specified Object to 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.
void setObjectForKey(MutableDictionary *self, const ident obj, const ident key)
Sets a pair in this MutableDictionary.
MutableDictionary * dictionary(void)
Returns a new MutableDictionary.
void addEntriesFromDictionary(MutableDictionary *self, const Dictionary *dictionary)
Adds the key-value entries from dictionary to this MutableDictionary.
void appendFormat(MutableString *self, const char *fmt,...)
Appends the specified formatted string.
void appendCharacters(MutableString *self, const char *chars)
Appends the specified UTF-8 encoded C string.
Object is the root Class of The Objectively Class hierarchy.
Class * _Object(void)
The Object archetype.
Object * copy(const Object *self)
Creates a shallow copy of this Object.
_Bool isKindOfClass(const Object *self, const Class *clazz)
Tests for Class hierarchy membership.
String * description(const Object *self)
_Bool isEqual(const Object *self, const Object *other)
Tests equality of the other Object.
int hash(const Object *self)
void dealloc(Object *self)
Frees all resources held by this Object.
char * chars
The backing null-terminated UTF-8 encoded character array.
OBJECTIVELY_EXPORT String * str(const char *fmt,...)
A convenience function for instantiating Strings.