mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
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:
parent
c8c11d5796
commit
2a7d95f055
1 changed files with 56 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue