mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 01:01:03 +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
|
@end
|
||||||
|
|
||||||
|
@interface GSOrderedSetEnumeratorReverse : GSOrderedSetEnumerator
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation GSOrderedSetEnumerator
|
@implementation GSOrderedSetEnumerator
|
||||||
- (id) initWithOrderedSet: (NSOrderedSet*)d
|
- (id) initWithOrderedSet: (NSOrderedSet*)d
|
||||||
{
|
{
|
||||||
|
@ -104,6 +107,30 @@ static SEL privateCountOfSel;
|
||||||
}
|
}
|
||||||
@end
|
@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
|
@implementation GSOrderedSet
|
||||||
|
|
||||||
static Class setClass;
|
static Class setClass;
|
||||||
|
@ -145,6 +172,11 @@ static Class mutableSetClass;
|
||||||
return AUTORELEASE([[GSOrderedSetEnumerator alloc] initWithOrderedSet: self]);
|
return AUTORELEASE([[GSOrderedSetEnumerator alloc] initWithOrderedSet: self]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSEnumerator*) reverseObjectEnumerator
|
||||||
|
{
|
||||||
|
return AUTORELEASE([[GSOrderedSetEnumeratorReverse alloc] initWithOrderedSet: self]);
|
||||||
|
}
|
||||||
|
|
||||||
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
||||||
objects: (id*)stackbuf
|
objects: (id*)stackbuf
|
||||||
count: (NSUInteger)len
|
count: (NSUInteger)len
|
||||||
|
|
|
@ -980,27 +980,56 @@ static SEL rlSel;
|
||||||
|
|
||||||
- (NSEnumerator *) objectEnumerator
|
- (NSEnumerator *) objectEnumerator
|
||||||
{
|
{
|
||||||
|
[self subclassResponsibility: _cmd];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSEnumerator *) reverseObjectEnumerator
|
- (NSEnumerator *) reverseObjectEnumerator
|
||||||
{
|
{
|
||||||
return nil;
|
[self subclassResponsibility: _cmd];
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSOrderedSet *)reversedOrderedSet
|
- (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
|
- (void) getObjects: (__unsafe_unretained id[])aBuffer range: (NSRange)aRange
|
||||||
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
|
// Key value coding support
|
||||||
- (void) setValue: (id)value forKey: (NSString*)key
|
- (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
|
- (id) valueForKey: (NSString*)key
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue