358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
[element retain];
[pool release];
[element autorelease];
return element;
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFEnumerator *enumerator = [self objectEnumerator];
id object;
BOOL stop = NO;
while (!stop && (object = [enumerator nextObject]) != nil)
block(object, &stop);
[pool release];
}
- (OFSet*)filteredSetUsingBlock: (of_set_filter_block_t)block
{
OFMutableSet *ret = [OFMutableSet set];
[self enumerateObjectsUsingBlock: ^ (id object, BOOL *stop) {
if (block(object))
[ret addObject: object];
|
|
<
<
<
|
>
|
|
|
>
>
>
|
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
[element retain];
[pool release];
[element autorelease];
return element;
}
#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
- (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block
{
BOOL stop = NO;
for (id object in self) {
block(object, &stop);
if (stop)
break;
}
}
#endif
#ifdef OF_HAVE_BLOCKS
- (OFSet*)filteredSetUsingBlock: (of_set_filter_block_t)block
{
OFMutableSet *ret = [OFMutableSet set];
[self enumerateObjectsUsingBlock: ^ (id object, BOOL *stop) {
if (block(object))
[ret addObject: object];
|