@@ -83,11 +83,11 @@ - initWithCapacity: (size_t)capacity { self = [super init]; @try { - mapTable = [[OFMapTable alloc] + _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions valueFunctions: valueFunctions capacity: capacity]; } @catch (id e) { [self release]; @@ -110,11 +110,11 @@ @try { OFDictionary_hashtable *dictionary_ = (OFDictionary_hashtable*)dictionary; - mapTable = [dictionary_->mapTable copy]; + _mapTable = [dictionary_->_mapTable copy]; } @catch (id e) { [self release]; @throw e; } @@ -137,12 +137,12 @@ keyEnumerator = [dictionary keyEnumerator]; objectEnumerator = [dictionary objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) - [mapTable setValue: object - forKey: key]; + [_mapTable setValue: object + forKey: key]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -155,12 +155,12 @@ forKey: (id)key { self = [self initWithCapacity: 1]; @try { - [mapTable setValue: object - forKey: key]; + [_mapTable setValue: object + forKey: key]; } @catch (id e) { [self release]; @throw e; } @@ -175,12 +175,12 @@ @try { size_t i; for (i = 0; i < count; i++) - [mapTable setValue: objects[i] - forKey: keys[i]]; + [_mapTable setValue: objects[i] + forKey: keys[i]]; } @catch (id e) { [self release]; @throw e; } @@ -213,17 +213,17 @@ count = 1; for (; va_arg(argumentsCopy, id) != nil; count++); count >>= 1; - mapTable = [[OFMapTable alloc] + _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions valueFunctions: valueFunctions capacity: count]; - [mapTable setValue: object - forKey: key]; + [_mapTable setValue: object + forKey: key]; for (i = 1; i < count; i++) { key = va_arg(arguments, id); object = va_arg(arguments, id); @@ -230,12 +230,12 @@ if (key == nil || object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; - [mapTable setValue: object - forKey: key]; + [_mapTable setValue: object + forKey: key]; } } @catch (id e) { [self release]; @throw e; } @@ -260,11 +260,11 @@ if ([keys count] != [objects count]) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; - mapTable = [[OFMapTable alloc] + _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions valueFunctions: valueFunctions capacity: [keys count]]; keyEnumerator = [keys objectEnumerator]; @@ -281,12 +281,12 @@ if (key == nil || object == nil) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; - [mapTable setValue: [object objectByDeserializing] - forKey: [key objectByDeserializing]]; + [_mapTable setValue: [object objectByDeserializing] + forKey: [key objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); @@ -295,19 +295,26 @@ @throw e; } return self; } + +- (void)dealloc +{ + [_mapTable dealloc]; + + [super dealloc]; +} - (id)objectForKey: (id)key { - return [mapTable valueForKey: key]; + return [_mapTable valueForKey: key]; } - (size_t)count { - return [mapTable count]; + return [_mapTable count]; } - (BOOL)isEqual: (id)dictionary { OFDictionary_hashtable *dictionary_; @@ -316,30 +323,30 @@ [self class] != [OFMutableDictionary_hashtable class]) return [super isEqual: dictionary]; dictionary_ = (OFDictionary_hashtable*)dictionary; - return [dictionary_->mapTable isEqual: mapTable]; + return [dictionary_->_mapTable isEqual: _mapTable]; } - (BOOL)containsObject: (id)object { - return [mapTable containsValue: object]; + return [_mapTable containsValue: object]; } - (BOOL)containsObjectIdenticalTo: (id)object { - return [mapTable containsValueIdenticalTo: object]; + return [_mapTable containsValueIdenticalTo: object]; } - (OFArray*)allKeys { OFArray *ret; id *keys; size_t count; - count = [mapTable count]; + count = [_mapTable count]; keys = [self allocMemoryWithSize: sizeof(*keys) count: count]; @try { void *pool = objc_autoreleasePoolPush(); @@ -346,11 +353,11 @@ OFMapTableEnumerator *enumerator; id key; size_t i; i = 0; - enumerator = [mapTable keyEnumerator]; + enumerator = [_mapTable keyEnumerator]; while ((key = [enumerator nextValue]) != nil) { assert(i < count); keys[i++] = key; } @@ -370,11 +377,11 @@ { OFArray *ret; id *objects; size_t count; - count = [mapTable count]; + count = [_mapTable count]; objects = [self allocMemoryWithSize: sizeof(*objects) count: count]; @try { void *pool = objc_autoreleasePoolPush(); @@ -381,11 +388,11 @@ OFMapTableEnumerator *enumerator; id object; size_t i; i = 0; - enumerator = [mapTable valueEnumerator]; + enumerator = [_mapTable valueEnumerator]; while ((object = [enumerator nextValue]) != nil) { assert(i < count); objects[i++] = object; } @@ -402,36 +409,36 @@ } - (OFEnumerator*)keyEnumerator { return [[[OFMapTableEnumeratorWrapper alloc] - initWithEnumerator: [mapTable keyEnumerator] + initWithEnumerator: [_mapTable keyEnumerator] object: self] autorelease]; } - (OFEnumerator*)objectEnumerator { return [[[OFMapTableEnumeratorWrapper alloc] - initWithEnumerator: [mapTable valueEnumerator] + initWithEnumerator: [_mapTable valueEnumerator] object: self] autorelease]; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects - count: (int)count_ + count: (int)count { - return [mapTable countByEnumeratingWithState: state - objects: objects - count: count_]; + return [_mapTable countByEnumeratingWithState: state + objects: objects + count: count]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndObjectsUsingBlock: (of_dictionary_enumeration_block_t)block { @try { - [mapTable enumerateKeysAndValuesUsingBlock: + [_mapTable enumerateKeysAndValuesUsingBlock: ^ (void *key, void *value, BOOL *stop) { block(key, value, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException @@ -439,17 +446,10 @@ object: self]; } } #endif -- (void)dealloc -{ - [mapTable dealloc]; - - [super dealloc]; -} - - (uint32_t)hash { - return [mapTable hash]; + return [_mapTable hash]; } @end