1 /* Copyright (c) 2006-2007 Christopher J. W. Lloyd
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
8 #import <Foundation/NSMutableDictionary_mapTable.h>
9 #import <Foundation/NSRaise.h>
10 #import <Foundation/NSArray.h>
11 #import <Foundation/NSEnumerator.h>
12 #import <Foundation/NSMutableDictionary_mapTable.h>
14 @implementation NSMutableDictionary
16 +allocWithZone:(NSZone *)zone {
17 return NSAllocateObject([NSMutableDictionary_CF class],0,zone);
20 -initWithCapacity:(NSUInteger)capacity {
21 NSInvalidAbstractInvocation();
25 -initWithObjects:(id *)objects forKeys:(id *)keys count:(NSUInteger)count {
28 self=[self initWithCapacity:count];
31 [self setObject:objects[i] forKey:keys[i]];
37 return [[NSDictionary allocWithZone:NULL] initWithDictionary:self];
40 -copyWithZone:(NSZone *)zone {
41 return [[NSDictionary allocWithZone:zone] initWithDictionary:self];
44 -(Class)classForCoder {
45 return objc_lookUpClass("NSMutableDictionary");
48 +dictionaryWithCapacity:(NSUInteger)capacity {
49 return [[[self allocWithZone:NULL] initWithCapacity:capacity] autorelease];
53 -(void)setObject:object forKey:aKey {
54 NSInvalidAbstractInvocation();
57 -(void)addEntriesFromDictionary:(NSDictionary *)dictionary {
58 NSEnumerator *keyEnum=[dictionary keyEnumerator];
61 while((key=[keyEnum nextObject])!=nil)
62 [self setObject:[dictionary objectForKey:key] forKey:key];
65 -(void)setDictionary:(NSDictionary *)dictionary {
66 [self removeAllObjects];
67 [self addEntriesFromDictionary:dictionary];
70 -(void)removeObjectForKey:aKey {
71 NSInvalidAbstractInvocation();
74 -(void)removeAllObjects {
75 NSArray *allKeys=[self allKeys];
76 NSInteger count=[allKeys count];
79 [self removeObjectForKey:[allKeys objectAtIndex:count]];
82 -(void)removeObjectsForKeys:(NSArray *)keys {
83 NSInteger count=[keys count];
86 [self removeObjectForKey:[keys objectAtIndex:count]];