Skip to content

Commit

Permalink
CPArray enumerateObjectsWithOptions:usingBlock:.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljungberg committed Mar 22, 2012
1 parent b99ece0 commit 2951a83
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion AppKit/CPTableView.j
Original file line number Diff line number Diff line change
Expand Up @@ -3050,7 +3050,6 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
return _sortDescriptors;
}


/*!
@ignore
*/
Expand Down
25 changes: 25 additions & 0 deletions Foundation/CPArray/CPArray.j
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,31 @@ var concat = Array.prototype.concat,
aFunction([self objectAtIndex:index], index);
}

- (void)enumerateObjectsWithOptions:(CPEnumerationOptions)options usingBlock:(Function /*(id anObject, int idx, @ref BOOL stop)*/)aFunction
{
var shouldStop = NO;

if (options & CPEnumerationReverse)
{
var index = [self count] - 1,
stop = -1,
increment = -1;
}
else
{
var index = 0,
stop = [self count],
increment = 1;
}

for (; index !== stop; index += increment)
{
aFunction([self objectAtIndex:index], index, AT_REF(shouldStop));
if (shouldStop)
return;
}
}

// Comparing arrays
/*!
Returns the first object found in the receiver (starting at index 0) which is present in the
Expand Down

0 comments on commit 2951a83

Please sign in to comment.