383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
objects: (id*)objects
count: (int)count_
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock:
(of_dictionary_enumeration_block_t)block
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFEnumerator *enumerator = [self keyEnumerator];
id key;
BOOL stop = NO;
while (!stop && (key = [enumerator nextObject]) != nil)
block(key, [self objectForKey: key], &stop);
[pool release];
}
- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block
{
OFMutableDictionary *new = [OFMutableDictionary dictionary];
[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
BOOL *stop) {
[new setObject: block(key, object)
|
|
<
<
<
|
>
|
|
|
>
>
>
|
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
objects: (id*)objects
count: (int)count_
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
- (void)enumerateKeysAndObjectsUsingBlock:
(of_dictionary_enumeration_block_t)block
{
BOOL stop = NO;
for (id key in self) {
block(key, [self objectForKey: key], &stop);
if (stop)
break;
}
}
#endif
#ifdef OF_HAVE_BLOCKS
- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block
{
OFMutableDictionary *new = [OFMutableDictionary dictionary];
[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
BOOL *stop) {
[new setObject: block(key, object)
|