00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <stdarg.h>
00018
00019 #import "OFObject.h"
00020 #import "OFCollection.h"
00021 #import "OFEnumerator.h"
00022
00023 @class OFArray;
00024
00025 #ifdef OF_HAVE_BLOCKS
00026 typedef void (^of_dictionary_enumeration_block_t)(id key, id obj, BOOL *stop);
00027 typedef BOOL (^of_dictionary_filter_block_t)(id key, id obj);
00028 typedef id (^of_dictionary_map_block_t)(id key, id obj);
00029 #endif
00030
00031 struct of_dictionary_bucket
00032 {
00033 id <OFCopying> key;
00034 id object;
00035 uint32_t hash;
00036 };
00037
00041 @interface OFDictionary: OFObject <OFCopying, OFMutableCopying, OFCollection,
00042 OFFastEnumeration>
00043 {
00044 struct of_dictionary_bucket **data;
00045 uint32_t size;
00046 size_t count;
00047 }
00048
00054 + dictionary;
00055
00062 + dictionaryWithDictionary: (OFDictionary*)dict;
00063
00071 + dictionaryWithObject: (id)obj
00072 forKey: (id <OFCopying>)key;
00073
00081 + dictionaryWithObjects: (OFArray*)objs
00082 forKeys: (OFArray*)keys;
00083
00090 + dictionaryWithKeysAndObjects: (id <OFCopying>)key, ...;
00091
00097 - init;
00098
00106 - initWithDictionary: (OFDictionary*)dict;
00107
00116 - initWithObject: (id)obj
00117 forKey: (id <OFCopying>)key;
00118
00127 - initWithObjects: (OFArray*)objs
00128 forKeys: (OFArray*)keys;
00129
00137 - initWithKeysAndObjects: (id <OFCopying>)first, ...;
00138
00147 - initWithKey: (id <OFCopying>)first
00148 argList: (va_list)args;
00149
00159 - (id)objectForKey: (id)key;
00160
00164 - (OFEnumerator*)keyEnumerator;
00165
00166 #ifdef OF_HAVE_BLOCKS
00167
00172 - (void)enumerateKeysAndObjectsUsingBlock:
00173 (of_dictionary_enumeration_block_t)block;
00174
00181 - (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block;
00182
00191 - (OFDictionary*)filteredDictionaryUsingBlock:
00192 (of_dictionary_filter_block_t)block;
00193 #endif
00194 @end
00195
00196 @interface OFDictionaryEnumerator: OFEnumerator
00197 {
00198 struct of_dictionary_bucket **data;
00199 uint32_t size;
00200 unsigned long mutations;
00201 unsigned long *mutationsPtr;
00202 uint32_t pos;
00203 }
00204
00205 - initWithData: (struct of_dictionary_bucket**)data
00206 size: (uint32_t)size
00207 mutationsPointer: (unsigned long*)mutations_ptr;
00208 @end
00209
00210 @interface OFDictionaryObjectEnumerator: OFDictionaryEnumerator
00211 @end
00212
00213 @interface OFDictionaryKeyEnumerator: OFDictionaryEnumerator
00214 @end
00215
00216 #import "OFMutableDictionary.h"
00217
00218 extern struct of_dictionary_bucket of_dictionary_deleted_bucket;