mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Correct issues brought up by Fred K.
This commit is contained in:
parent
d66ad25b50
commit
268b2203c7
2 changed files with 66 additions and 5 deletions
|
@ -73,6 +73,9 @@ static SEL privateCountOfSel;
|
|||
}
|
||||
@end
|
||||
|
||||
@interface GSOrderedSetEnumeratorReverse : GSOrderedSetEnumerator
|
||||
@end
|
||||
|
||||
@implementation GSOrderedSetEnumerator
|
||||
- (id) initWithOrderedSet: (NSOrderedSet*)d
|
||||
{
|
||||
|
@ -104,6 +107,30 @@ static SEL privateCountOfSel;
|
|||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation GSOrderedSetEnumeratorReverse
|
||||
- (id) initWithOrderedSet: (GSOrderedSet*)d
|
||||
{
|
||||
self = [super initWithOrderedSet: d];
|
||||
if(self != nil)
|
||||
{
|
||||
current = GSIArrayCount(&set->array);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) nextObject
|
||||
{
|
||||
GSIArrayItem item;
|
||||
|
||||
if (current == 0)
|
||||
return nil;
|
||||
|
||||
item = GSIArrayItemAtIndex(&set->array, --current);
|
||||
return (id)(item.obj);
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GSOrderedSet
|
||||
|
||||
static Class setClass;
|
||||
|
@ -145,6 +172,11 @@ static Class mutableSetClass;
|
|||
return AUTORELEASE([[GSOrderedSetEnumerator alloc] initWithOrderedSet: self]);
|
||||
}
|
||||
|
||||
- (NSEnumerator*) reverseObjectEnumerator
|
||||
{
|
||||
return AUTORELEASE([[GSOrderedSetEnumeratorReverse alloc] initWithOrderedSet: self]);
|
||||
}
|
||||
|
||||
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
||||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
|
|
|
@ -980,27 +980,56 @@ static SEL rlSel;
|
|||
|
||||
- (NSEnumerator *) objectEnumerator
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSEnumerator *) reverseObjectEnumerator
|
||||
{
|
||||
return nil;
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSOrderedSet *)reversedOrderedSet
|
||||
{
|
||||
return nil;
|
||||
NSEnumerator *e = [self reverseObjectEnumerator];
|
||||
NSMutableArray *a = [NSMutableArray arrayWithCapacity: [self count]];
|
||||
id o = nil;
|
||||
|
||||
// Build the reverse array...
|
||||
while ((o = [e nextObject]) != nil)
|
||||
{
|
||||
[a addObject: o];
|
||||
}
|
||||
|
||||
// Create and return reverse ordered set...
|
||||
return [NSOrderedSet orderedSetWithArray: a];
|
||||
}
|
||||
|
||||
- (void) getObjects: (__unsafe_unretained id[])aBuffer
|
||||
range: (NSRange)aRange
|
||||
- (void) getObjects: (__unsafe_unretained id[])aBuffer range: (NSRange)aRange
|
||||
{
|
||||
}
|
||||
NSUInteger i, j = 0, c = [self count], e = aRange.location + aRange.length;
|
||||
IMP get = [self methodForSelector: oaiSel];
|
||||
|
||||
GS_RANGE_CHECK(aRange, c);
|
||||
|
||||
for (i = aRange.location; i < e; i++)
|
||||
aBuffer[j++] = (*get)(self, oaiSel, i);
|
||||
}
|
||||
|
||||
// Key value coding support
|
||||
- (void) setValue: (id)value forKey: (NSString*)key
|
||||
{
|
||||
NSUInteger i;
|
||||
NSUInteger count = [self count];
|
||||
volatile id object = nil;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
object = [self objectAtIndex: i];
|
||||
[object setValue: value
|
||||
forKey: key];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) valueForKey: (NSString*)key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue