1 /* 2 Copyright (C) 2000-2005 SKYRIX Software AG 3 4 This file is part of SOPE. 5 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 9 later version. 10 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. 15 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 19 02111-1307, USA. 20 */ 21 22 #ifndef __NGExtensions_NGHashMap_H__ 23 #define __NGExtensions_NGHashMap_H__ 24 25 #import <Foundation/NSObject.h> 26 #import <Foundation/NSMapTable.h> 27 28 @class NSArray, NSDictionary; 29 30 @interface NGHashMap : NSObject < NSCopying, NSMutableCopying, NSCoding > 31 { 32 @protected 33 NSMapTable *table; 34 } 35 36 + (id)hashMap; 37 + (id)hashMapWithHashMap:(NGHashMap *)_hashMap; 38 + (id)hashMapWithObjects:(NSArray *)_objects forKey:(id)_key; 39 + (id)hashMapWithDictionary:(NSDictionary *)_dict; 40 41 - (id)init; 42 - (id)initWithCapacity:(NSUInteger)_size; 43 - (id)initWithObjects:(NSArray *)_objects forKey:(id)_key; 44 - (id)initWithHashMap:(NGHashMap *)_hashMap; 45 - (id)initWithDictionary:(NSDictionary *)_dictionary; 46 47 - (BOOL)isEqual:(id)anObject; 48 - (BOOL)isEqualToHashMap:(NGHashMap *)_other; 49 50 - (id)objectForKey:(id)_key; 51 - (NSArray *)objectsForKey:(id)_key; 52 - (id)objectAtIndex:(NSUInteger)_index forKey:(id)_key; 53 54 - (NSArray *)allKeys; 55 - (NSArray *)allObjects; 56 57 - (NSEnumerator *)keyEnumerator; 58 - (NSEnumerator *)objectEnumerator; 59 - (NSEnumerator *)objectEnumeratorForKey:(id)_key; 60 61 - (id)propertyList; 62 - (NSString *)description; 63 - (NSDictionary *)asDictionary; 64 - (NSDictionary *)asDictionaryWithArraysForValues; 65 66 - (NSUInteger)hash; 67 - (NSUInteger)count; // returns the number of keys 68 - (NSUInteger)countObjectsForKey:(id)_key; 69 70 @end 71 72 @interface NGMutableHashMap : NGHashMap 73 { 74 } 75 76 + (id)hashMapWithCapacity:(NSUInteger)_numItems; 77 78 - (id)init; 79 80 - (void)insertObject:(id)_object atIndex:(NSUInteger)_index forKey:(id)_key; 81 - (void)insertObjects:(NSArray *)_object 82 atIndex:(NSUInteger)_index forKey:(id)_key; 83 - (void)insertObjects:(id*)_objects count:(NSUInteger)_count 84 atIndex:(NSUInteger)_index forKey:(id)_key; 85 86 - (void)addObject:(id)_object forKey:(id)_key; 87 - (void)addObjects:(NSArray *)_objects forKey:(id)_key; 88 - (void)addObjects:(id*)_objects count:(NSUInteger)_count 89 forKey:(id)_key; 90 91 - (void)setObject:(id)_object forKey:(id)_key; 92 - (void)setObjects:(NSArray *)_objects forKey:(id)_key; 93 94 - (void)removeAllObjects; 95 - (void)removeAllObjects:(id)_object forKey:(id)_key; 96 - (void)removeAllObjectsForKey:(id)_key; 97 - (void)removeAllObjectsForKeys:(NSArray *)_keyArray; 98 99 @end 100 101 #endif /* __NGExtensions_NGHashMap_H__ */ 102