00001 /* 00002 * Copyright (c) 2008 - 2009 00003 * Jonathan Schleifer <js@webkeks.org> 00004 * 00005 * All rights reserved. 00006 * 00007 * This file is part of ObjFW. It may be distributed under the terms of the 00008 * Q Public License 1.0, which can be found in the file LICENSE included in 00009 * the packaging of this file. 00010 */ 00011 00012 #include <stdarg.h> 00013 00014 #import "OFObject.h" 00015 #import "OFEnumerator.h" 00016 00017 @class OFArray; 00018 00019 struct of_dictionary_bucket 00020 { 00021 OFObject <OFCopying> *key; 00022 OFObject *object; 00023 uint32_t hash; 00024 }; 00025 00029 @interface OFDictionary: OFObject <OFCopying, OFMutableCopying, 00030 OFFastEnumeration> 00031 { 00032 struct of_dictionary_bucket *data; 00033 size_t size; 00034 size_t count; 00035 } 00036 00042 + dictionary; 00043 00050 + dictionaryWithDictionary: (OFDictionary*)dict; 00051 00059 + dictionaryWithObject: (OFObject*)obj 00060 forKey: (OFObject <OFCopying>*)key; 00061 00069 + dictionaryWithObjects: (OFArray*)objs 00070 forKeys: (OFArray*)keys; 00071 00078 + dictionaryWithKeysAndObjects: (OFObject <OFCopying>*)key, ...; 00079 00085 - init; 00086 00094 - initWithDictionary: (OFDictionary*)dict; 00095 00104 - initWithObject: (OFObject*)obj 00105 forKey: (OFObject <OFCopying>*)key; 00106 00115 - initWithObjects: (OFArray*)objs 00116 forKeys: (OFArray*)keys; 00117 00125 - initWithKeysAndObjects: (OFObject <OFCopying>*)first, ...; 00126 00135 - initWithKey: (OFObject <OFCopying>*)first 00136 argList: (va_list)args; 00137 00142 - (id)objectForKey: (OFObject <OFCopying>*)key; 00143 00147 - (size_t)count; 00148 00152 - (OFEnumerator*)objectEnumerator; 00153 00157 - (OFEnumerator*)keyEnumerator; 00158 @end 00159 00160 @interface OFDictionaryEnumerator: OFEnumerator 00161 { 00162 struct of_dictionary_bucket *data; 00163 size_t size; 00164 unsigned long mutations; 00165 unsigned long *mutations_ptr; 00166 size_t pos; 00167 } 00168 00169 - initWithData: (struct of_dictionary_bucket*)data 00170 size: (size_t)size 00171 mutationsPointer: (unsigned long*)mutations_ptr; 00172 @end 00173 00174 @interface OFDictionaryObjectEnumerator: OFDictionaryEnumerator 00175 @end 00176 00177 @interface OFDictionaryKeyEnumerator: OFDictionaryEnumerator 00178 @end 00179 00180 #import "OFMutableDictionary.h"