diff options
Diffstat (limited to 'Source/SPArrayAdditions.m')
-rw-r--r-- | Source/SPArrayAdditions.m | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/SPArrayAdditions.m b/Source/SPArrayAdditions.m index 66473d81..853421e0 100644 --- a/Source/SPArrayAdditions.m +++ b/Source/SPArrayAdditions.m @@ -42,4 +42,21 @@ return result; } +- (NSArray *)subarrayWithIndexes:(NSIndexSet *)indexes +{ + NSMutableArray *subArray = [NSMutableArray arrayWithCapacity:[indexes count]]; + unsigned count = [self count]; + + unsigned index = [indexes firstIndex]; + while ( index != NSNotFound ) + { + if ( index < count ) + [subArray addObject: [self objectAtIndex: index]]; + + index = [indexes indexGreaterThanIndex: index]; + } + + return subArray; +} + @end |