8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
-
+
-
+
-
-
-
+
-
-
-
+
-
+
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
|
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#include <stdarg.h>
#import "OFObject.h"
#import "OFList.h"
#import "OFArray.h"
typedef struct __of_dictionary_list_object
struct of_dictionary_bucket
{
/* of_list_object_t */
OFObject <OFCopying> *key;
struct __of_dictionary_list_object *next;
struct __of_dictionary_list_object *prev;
id object;
OFObject *object;
/* OFDictionary additions */
id key;
uint32_t hash;
uint32_t hash;
} of_dictionary_list_object_t;
};
/**
* The OFDictionary class provides a class for using hash tables.
*/
@interface OFDictionary: OFObject <OFCopying, OFMutableCopying>
{
OFList **data;
size_t size;
struct of_dictionary_bucket *data;
size_t size;
size_t count;
}
/**
* Creates a new OFDictionary, defaulting to a 12 bit hash.
* Creates a new OFDictionary.
*
* \return A new autoreleased OFDictionary
*/
+ dictionary;
/**
* Creates a new OFDictionary with the specified dictionary.
*
* \param dict An OFDictionary
* \return A new autoreleased OFDictionary
*/
+ dictionaryWithDictionary: (OFDictionary*)dict;
/**
* Creates a new OFDictionary with a hash of N bits.
*
* \param bits The size of the hash to use
* \return A new autoreleased OFDictionary
*/
+ dictionaryWithHashSize: (int)hashsize;
/**
* Creates a new OFDictionary with the specified key and object.
*
* \param key The key
* \param obj The object
* \return A new autoreleased OFDictionary
*/
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
-
+
-
+
-
+
-
-
-
-
-
-
-
-
|
*/
+ dictionaryWithObjects: (OFArray*)objs
forKeys: (OFArray*)keys;
/**
* Creates a new OFDictionary with the specified keys objects.
*
* \param first The first key
* \param key The first key
* \return A new autoreleased OFDictionary
*/
+ dictionaryWithKeysAndObjects: (OFObject <OFCopying>*)first, ...;
+ dictionaryWithKeysAndObjects: (OFObject <OFCopying>*)key, ...;
/**
* Initializes an already allocated OFDictionary, defaulting to a 12 bit hash.
* Initializes an already allocated OFDictionary.
*
* \return An initialized OFDictionary
*/
- init;
/**
* Initializes an already allocated OFDictionary with the specified
* OFDictionary.
*
* \param dict An OFDictionary
* \return An initialized OFDictionary
*/
- initWithDictionary: (OFDictionary*)dict;
/**
* Initializes an already allocated OFDictionary with a hash of N bits.
*
* \param bits The size of the hash to use
* \return An initialized OFDictionary
*/
- initWithHashSize: (int)hashsize;
/**
* Initializes an already allocated OFDictionary with the specified key and
* object.
*
* \param key The key
* \param obj The object
* \return A new initialized OFDictionary
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
|
*
* \param first The first key
* \return A new initialized OFDictionary
*/
- initWithKey: (OFObject <OFCopying>*)first
argList: (va_list)args;
/**
* \return The average number of items in a used bucket. Buckets that are
* completely empty are not in the calculation. If this value is >= 2.0,
* you should resize the dictionary, in most cases even earlier!
*/
- (float)averageItemsPerBucket;
/**
* \param key The key whose object should be returned
* \return The object for the given key or nil if the key was not found
*/
- (id)objectForKey: (OFObject*)key;
- (id)objectForKey: (OFObject <OFCopying>*)key;
/**
* \return The number of objects in the dictionary
*/
- (size_t)count;
- setObject: (OFObject*)obj
forKey: (OFObject <OFCopying>*)key;
- removeObjectForKey: (OFObject*)key;
- changeHashSize: (int)hashsize;
@end
#import "OFIterator.h"
#import "OFMutableDictionary.h"
|