mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-06 18:57:12 +00:00
Implement stopping support for CPArray enumerateObjectsUsingBlock:.
This commit is contained in:
@@ -536,13 +536,21 @@ var concat = Array.prototype.concat,
|
||||
objj_msgSend([self objectAtIndex:index], aSelector);
|
||||
}
|
||||
|
||||
- (void)enumerateObjectsUsingBlock:(Function)aFunction
|
||||
- (void)enumerateObjectsUsingBlock:(Function /*(id anObject, int idx, @ref BOOL stop)*/)aFunction
|
||||
{
|
||||
// This could have been [self enumerateObjectsWithOptions:CPEnumerationNormal usingBlock:aFunction]
|
||||
// but this method should be as fast as possible.
|
||||
var index = 0,
|
||||
count = [self count];
|
||||
count = [self count],
|
||||
shouldStop = NO,
|
||||
shouldStopRef = AT_REF(shouldStop);
|
||||
|
||||
for (; index < count; ++index)
|
||||
aFunction([self objectAtIndex:index], index);
|
||||
{
|
||||
aFunction([self objectAtIndex:index], index, shouldStopRef);
|
||||
if (shouldStop)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)enumerateObjectsWithOptions:(CPEnumerationOptions)options usingBlock:(Function /*(id anObject, int idx, @ref BOOL stop)*/)aFunction
|
||||
|
||||
Reference in New Issue
Block a user