1
2
3
4
5
6
7
8
9
10
11
|
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
* 2018, 2019, 2020
* Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
<
<
|
|
1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | | ︙ | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
{
return (id)[[OFMutableMapTableDictionary alloc]
initWithDictionary: dictionary];
}
- (instancetype)initWithObject: (id)object
forKey: (id)key
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObject: object
forKey: key];
}
- (instancetype)initWithObjects: (OFArray *)objects
forKeys: (OFArray *)keys
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObjects: objects
forKeys: keys];
}
- (instancetype)initWithObjects: (id const *)objects
forKeys: (id const *)keys
|
|
<
|
<
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
{
return (id)[[OFMutableMapTableDictionary alloc]
initWithDictionary: dictionary];
}
- (instancetype)initWithObject: (id)object forKey: (id)key
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObject: object
forKey: key];
}
- (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObjects: objects
forKeys: keys];
}
- (instancetype)initWithObjects: (id const *)objects
forKeys: (id const *)keys
|
︙ | | | ︙ | |
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
ret = (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithKey: (id)firstKey
arguments: (va_list)arguments
{
return (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
|
|
<
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
ret = (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
return (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
|
︙ | | | ︙ | |
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
}
- (instancetype)initWithCapacity: (size_t)capacity
{
OF_INVALID_INIT_METHOD
}
- (void)setObject: (id)object
forKey: (id)key
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)setObject: (id)object
forKeyedSubscript: (id)key
{
if (object != nil)
[self setObject: object
forKey: key];
else
[self removeObjectForKey: key];
}
- (void)removeObjectForKey: (id)key
{
OF_UNRECOGNIZED_SELECTOR
|
|
<
|
<
|
<
|
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
}
- (instancetype)initWithCapacity: (size_t)capacity
{
OF_INVALID_INIT_METHOD
}
- (void)setObject: (id)object forKey: (id)key
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)setObject: (id)object forKeyedSubscript: (id)key
{
if (object != nil)
[self setObject: object forKey: key];
else
[self removeObjectForKey: key];
}
- (void)removeObjectForKey: (id)key
{
OF_UNRECOGNIZED_SELECTOR
|
︙ | | | ︙ | |
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
void *pool = objc_autoreleasePoolPush();
OFEnumerator *keyEnumerator = [dictionary keyEnumerator];
OFEnumerator *objectEnumerator = [dictionary objectEnumerator];
id key, object;
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
[self setObject: object
forKey: key];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
bool *stop) {
id new = block(key, object);
if (new != object) {
[self setObject: block(key, object)
forKey: key];
}
}];
}
#endif
- (void)makeImmutable
{
}
@end
|
|
<
|
<
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
void *pool = objc_autoreleasePoolPush();
OFEnumerator *keyEnumerator = [dictionary keyEnumerator];
OFEnumerator *objectEnumerator = [dictionary objectEnumerator];
id key, object;
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
[self setObject: object forKey: key];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
bool *stop) {
id new = block(key, object);
if (new != object) {
[self setObject: block(key, object) forKey: key];
}
}];
}
#endif
- (void)makeImmutable
{
}
@end
|