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