2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #import "NSDictionary+misc.h"
25 @implementation NSDictionary(misc)
27 - (NSDictionary *)dictionaryByExchangingKeysAndValues {
28 NSDictionary *reverse;
33 oKeys = [self allKeys];
34 if ((len = [oKeys count]) == 0)
35 return [[self copy] autorelease];
37 keys = calloc(len + 10, sizeof(id));
38 values = calloc(len + 10, sizeof(id));
39 for (i = 0; i < len; i++) {
40 values[i] = [oKeys objectAtIndex:i];
41 keys[i] = [self objectForKey:values[i]];
45 [[NSDictionary alloc] initWithObjects:values forKeys:keys count:len];
48 return [reverse autorelease];
51 @end /* NSDictionary(misc) */
53 @implementation NSMutableDictionary(misc)
55 - (void)removeObjectsForKeysV:(id)_firstKey, ... {
58 va_start(ap, _firstKey);
60 [self removeObjectForKey:_firstKey];
61 _firstKey = va_arg(ap, id);
66 @end /* NSMutableDictionary(misc) */
68 void __link_NSDictionary_misc() {
69 __link_NSDictionary_misc();