Add fast enumeration

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27711 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-01-28 12:03:41 +00:00
parent 2309fc7d1e
commit afb0f171c7
3 changed files with 40 additions and 1 deletions

View file

@ -74,4 +74,23 @@
return nil;
}
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
objects: (id*)stackbuf
count: (NSUInteger)len
{
IMP nextObject = [self methodForSelector: @selector(nextObject)];
int i;
for (i = 0; i < len; i++)
{
id next = nextObject(self, @selector(nextObject));
if (nil == next)
{
return i;
}
*(stackbuf+i) = next;
}
return len;
}
@end