Moved NSArrayEnumerator interface and implementation from separate

files to here.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@485 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1995-07-01 18:38:03 +00:00
parent c8c11d5796
commit 2a7d95f055

View file

@ -25,8 +25,63 @@
#include <Foundation/NSArray.h>
#include <Foundation/NSString.h>
#include <Foundation/NSGArray.h>
#include <Foundation/NSArrayEnumerator.h>
#include <limits.h>
#include <Foundation/NSUtilities.h>
@interface NSArrayEnumerator : NSEnumerator
{
id array;
int next_index;
}
@end
@interface NSArrayEnumeratorReverse : NSArrayEnumerator
@end
@implementation NSArrayEnumerator
- initWithArray: (NSArray*)anArray
{
[super init];
array = anArray;
[array retain];
next_index = 0;
return self;
}
- (id) nextObject
{
if (next_index >= [array count])
return nil;
return [array objectAtIndex:next_index++];
}
- (void) dealloc
{
[array release];
[super dealloc];
}
@end
@implementation NSArrayEnumeratorReverse
- initWithArray: (NSArray*)anArray
{
[super init];
array = anArray;
[array retain];
next_index = [array count]-1;
return self;
}
- (id) nextObject
{
if (next_index < 0)
return nil;
return [array objectAtIndex:next_index--];
}
@implementation NSArray