47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
static bool
equal(void *object1, void *object2)
{
return [(id)object1 isEqual: (id)object2];
}
static const of_map_table_functions_t keyFunctions = {
.retain = retain,
.release = release,
.hash = hash,
.equal = equal
};
static const of_map_table_functions_t objectFunctions = { NULL };
@implementation OFMapTableSet
- (instancetype)init
{
return [self initWithCapacity: 0];
}
|
|
|
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
static bool
equal(void *object1, void *object2)
{
return [(id)object1 isEqual: (id)object2];
}
static const OFMapTableFunctions keyFunctions = {
.retain = retain,
.release = release,
.hash = hash,
.equal = equal
};
static const OFMapTableFunctions objectFunctions = { NULL };
@implementation OFMapTableSet
- (instancetype)init
{
return [self initWithCapacity: 0];
}
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if ((![element.name isEqual: @"OFSet"] &&
![element.name isEqual: @"OFMutableSet"]) ||
![element.namespace isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
[element elementsForNamespace: OF_SERIALIZATION_NS]) {
void *pool2 = objc_autoreleasePoolPush();
[_mapTable setObject: (void *)1
forKey: [child objectByDeserializing]];
objc_autoreleasePoolPop(pool2);
}
|
|
|
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if ((![element.name isEqual: @"OFSet"] &&
![element.name isEqual: @"OFMutableSet"]) ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
[element elementsForNamespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
[_mapTable setObject: (void *)1
forKey: [child objectByDeserializing]];
objc_autoreleasePoolPop(pool2);
}
|
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
- (OFEnumerator *)objectEnumerator
{
return [[[OFMapTableEnumeratorWrapper alloc]
initWithEnumerator: [_mapTable keyEnumerator]
object: self] autorelease];
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state
objects: (id *)objects
count: (int)count
{
return [_mapTable countByEnumeratingWithState: state
objects: objects
count: count];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block
{
@try {
[_mapTable enumerateKeysAndObjectsUsingBlock:
^ (void *key, void *object, bool *stop) {
block(key, stop);
}];
} @catch (OFEnumerationMutationException *e) {
@throw [OFEnumerationMutationException
exceptionWithObject: self];
}
}
#endif
@end
|
|
|
|
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
- (OFEnumerator *)objectEnumerator
{
return [[[OFMapTableEnumeratorWrapper alloc]
initWithEnumerator: [_mapTable keyEnumerator]
object: self] autorelease];
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
return [_mapTable countByEnumeratingWithState: state
objects: objects
count: count];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (OFSetEnumerationBlock)block
{
@try {
[_mapTable enumerateKeysAndObjectsUsingBlock:
^ (void *key, void *object, bool *stop) {
block(key, stop);
}];
} @catch (OFEnumerationMutationException *e) {
@throw [OFEnumerationMutationException
exceptionWithObject: self];
}
}
#endif
@end
|