Correct issues brought up by Fred K.

This commit is contained in:
Gregory John Casamento 2019-06-10 13:55:00 -04:00
parent d66ad25b50
commit 268b2203c7
2 changed files with 66 additions and 5 deletions

View file

@ -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