Review of KVC and improvements by Chris Farber

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25313 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2007-07-10 17:16:31 +00:00
parent bf24d21cb4
commit 6848cb6de9
7 changed files with 1385 additions and 9 deletions

View file

@ -47,6 +47,7 @@
#include "Foundation/NSValue.h"
#include "Foundation/NSNull.h"
#include "Foundation/NSUserDefaults.h"
#include "Foundation/NSIndexSet.h"
// For private method _decodeArrayOfObjectsForKey:
#include "Foundation/NSKeyedArchiver.h"
#include "GNUstepBase/GSCategories.h"
@ -835,6 +836,21 @@ static SEL rlSel;
return nil;
}
- (NSArray *) objectsAtIndexes: (NSIndexSet *)indexes
{
//FIXME: probably slow!
NSMutableArray * group = [NSMutableArray arrayWithCapacity: [indexes count]];
unsigned i = [indexes firstIndex];
while (i != NSNotFound)
{
[group addObject: [self objectAtIndex: i]];
i = [indexes indexGreaterThanIndex: i];
}
return [group copy];
}
- (BOOL) isEqual: (id)anObject
{
if (self == anObject)
@ -844,6 +860,7 @@ static SEL rlSel;
return NO;
}
/**
* Returns YES if the receiver is equal to otherArray, NO otherwise.
*/
@ -1706,6 +1723,22 @@ compare(id elem1, id elem2, void* context)
[self addObjectsFromArray: otherArray];
}
/**
* Removes objects from the receiver at the indices supplied by an NSIndexSet
*/
- (void) removeObjectsAtIndexes: (NSIndexSet *)indexes
{
unsigned count = [indexes count];
unsigned indexArray[count];
[indexes getIndexes: indexArray
maxCount:count
inIndexRange: NULL];
[self removeObjectsFromIndices: indexArray
numIndices: count];
}
/**
* Supplied with a C array of indices containing count values, this method
* removes all corresponding objects from the receiver. The objects are