mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-04 10:30:47 +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
e9b61a4450
commit
783733a346
1 changed files with 56 additions and 1 deletions
|
@ -25,8 +25,63 @@
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSGArray.h>
|
#include <Foundation/NSGArray.h>
|
||||||
#include <Foundation/NSArrayEnumerator.h>
|
|
||||||
#include <limits.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
|
@implementation NSArray
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue