1995-04-03 22:59:20 +00:00
|
|
|
/* NSArray - Array object to hold other objects.
|
1996-02-01 17:04:17 +00:00
|
|
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
1995-04-04 16:01:04 +00:00
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
|
|
|
From skeleton by: Adam Fedor <fedor@boulder.colorado.edu>
|
|
|
|
Date: March 1995
|
1995-04-04 16:01:04 +00:00
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
This file is part of the GNU Objective C Class Library.
|
1995-04-04 16:01:04 +00:00
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
1995-04-04 16:01:04 +00:00
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
1995-04-04 16:01:04 +00:00
|
|
|
*/
|
1995-04-03 22:59:20 +00:00
|
|
|
|
1995-04-17 21:13:20 +00:00
|
|
|
#include <Foundation/NSArray.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSGArray.h>
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
#include <limits.h>
|
1995-07-01 18:38:03 +00:00
|
|
|
#include <Foundation/NSUtilities.h>
|
1995-10-22 17:59:25 +00:00
|
|
|
#include <Foundation/NSException.h>
|
1995-07-01 18:38:03 +00:00
|
|
|
|
|
|
|
@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--];
|
|
|
|
}
|
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
|
|
@implementation NSArray
|
|
|
|
|
1995-06-30 13:45:13 +00:00
|
|
|
static Class NSArray_concrete_class;
|
1995-06-30 14:07:44 +00:00
|
|
|
static Class NSMutableArray_concrete_class;
|
1995-06-30 13:45:13 +00:00
|
|
|
|
|
|
|
+ (void) _setConcreteClass: (Class)c
|
|
|
|
{
|
|
|
|
NSArray_concrete_class = c;
|
|
|
|
}
|
|
|
|
|
1995-06-30 14:07:44 +00:00
|
|
|
+ (void) _setMutableConcreteClass: (Class)c
|
|
|
|
{
|
|
|
|
NSMutableArray_concrete_class = c;
|
|
|
|
}
|
|
|
|
|
1995-06-30 13:45:13 +00:00
|
|
|
+ (Class) _concreteClass
|
|
|
|
{
|
|
|
|
return NSArray_concrete_class;
|
|
|
|
}
|
|
|
|
|
1995-06-30 14:07:44 +00:00
|
|
|
+ (Class) _mutableConcreteClass
|
|
|
|
{
|
|
|
|
return NSMutableArray_concrete_class;
|
|
|
|
}
|
|
|
|
|
1995-06-30 13:45:13 +00:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
NSArray_concrete_class = [NSGArray class];
|
1995-06-30 14:07:44 +00:00
|
|
|
NSMutableArray_concrete_class = [NSGMutableArray class];
|
1995-06-30 13:45:13 +00:00
|
|
|
}
|
|
|
|
|
1995-05-05 15:50:26 +00:00
|
|
|
+ allocWithZone: (NSZone*)z
|
|
|
|
{
|
1995-06-30 13:45:13 +00:00
|
|
|
return NSAllocateObject([self _concreteClass], 0, z);
|
1995-05-05 15:50:26 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
+ array
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-11-03 22:22:02 +00:00
|
|
|
return [[[self alloc] init]
|
1995-06-30 13:45:13 +00:00
|
|
|
autorelease];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
+ arrayWithObject: anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-11-03 22:22:02 +00:00
|
|
|
if (anObject == nil)
|
|
|
|
[NSException raise:NSInvalidArgumentException
|
|
|
|
format:@"Tried to add nil"];
|
|
|
|
return [[[self alloc] initWithObjects:&anObject count:1]
|
1995-06-30 13:45:13 +00:00
|
|
|
autorelease];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
1996-03-30 19:14:43 +00:00
|
|
|
- (NSArray*) arrayByAddingObject: anObject
|
|
|
|
{
|
|
|
|
id na;
|
|
|
|
int i, c;
|
|
|
|
id *objects;
|
|
|
|
|
|
|
|
c = [self count];
|
|
|
|
OBJC_MALLOC (objects, id, c+1);
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
objects[i] = [self objectAtIndex: i];
|
|
|
|
objects[c] = anObject;
|
|
|
|
na = [[NSArray alloc] initWithObjects: objects count: c+1];
|
|
|
|
OBJC_FREE (objects);
|
|
|
|
return na;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray*) arrayByAddingObjectsFromArray: (NSArray*)anotherArray
|
|
|
|
{
|
|
|
|
id na;
|
|
|
|
int i, c, l;
|
|
|
|
id *objects;
|
|
|
|
|
|
|
|
c = [self count];
|
|
|
|
l = [anotherArray count];
|
|
|
|
OBJC_MALLOC (objects, id, c+l);
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
objects[i] = [self objectAtIndex: i];
|
|
|
|
for (i = c; i < c+l; i++)
|
|
|
|
objects[i] = [anotherArray objectAtIndex: i-c];
|
|
|
|
na = [[NSArray alloc] initWithObjects: objects count: c+l];
|
|
|
|
OBJC_FREE (objects);
|
|
|
|
return na;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* This is the designated initializer for NSArray. */
|
|
|
|
- initWithObjects: (id*)objects count: (unsigned)count
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1996-02-01 17:04:17 +00:00
|
|
|
[self subclassResponsibility:_cmd];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
return nil;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* Not very pretty... */
|
|
|
|
#define INITIAL_OBJECTS_SIZE 10
|
|
|
|
- initWithObjects: firstObject rest: (va_list)ap
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
id *objects;
|
|
|
|
int i = 0;
|
|
|
|
int s = INITIAL_OBJECTS_SIZE;
|
|
|
|
|
|
|
|
OBJC_MALLOC(objects, id, s);
|
|
|
|
if (firstObject != nil)
|
|
|
|
{
|
|
|
|
objects[i++] = firstObject;
|
|
|
|
while ((objects[i++] = va_arg(ap, id)))
|
|
|
|
{
|
|
|
|
if (i >= s)
|
|
|
|
{
|
|
|
|
s *= 2;
|
|
|
|
OBJC_REALLOC(objects, id, s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self = [self initWithObjects:objects count:i-1];
|
|
|
|
OBJC_FREE(objects);
|
|
|
|
return self;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- initWithObjects: firstObject, ...
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, firstObject);
|
|
|
|
self = [self initWithObjects:firstObject rest:ap];
|
|
|
|
va_end(ap);
|
1995-04-04 16:01:04 +00:00
|
|
|
return self;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
+ arrayWithObjects: firstObject, ...
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-04-04 16:01:04 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, firstObject);
|
1995-11-03 22:22:02 +00:00
|
|
|
self = [[self alloc] initWithObjects:firstObject rest:ap];
|
1995-04-04 16:01:04 +00:00
|
|
|
va_end(ap);
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
return [self autorelease];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
|
|
|
|
- initWithArray: (NSArray*)array
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-04-04 16:01:04 +00:00
|
|
|
int i, c;
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
id *objects;
|
1995-04-04 16:01:04 +00:00
|
|
|
|
|
|
|
c = [array count];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
OBJC_MALLOC(objects, id, c);
|
1995-04-04 16:01:04 +00:00
|
|
|
for (i = 0; i < c; i++)
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
objects[i] = [array objectAtIndex:i];
|
|
|
|
return [self initWithObjects:objects count:c];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (unsigned) count
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1996-02-01 17:04:17 +00:00
|
|
|
[self subclassResponsibility:_cmd];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
return 0;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- objectAtIndex: (unsigned)index
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1996-02-01 17:04:17 +00:00
|
|
|
[self subclassResponsibility:_cmd];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
return nil;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (unsigned) indexOfObjectIdenticalTo:anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int i, c = [self count];
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
if (anObject == [self objectAtIndex:i])
|
|
|
|
return i;
|
1995-09-21 17:42:46 +00:00
|
|
|
return NSNotFound;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* Inefficient, should be overridden. */
|
|
|
|
- (unsigned) indexOfObject: anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int i, c = [self count];
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
if ([[self objectAtIndex:i] isEqual: anObject])
|
|
|
|
return i;
|
1995-09-21 17:42:46 +00:00
|
|
|
return NSNotFound;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (BOOL) containsObject: anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-09-21 17:42:46 +00:00
|
|
|
return ([self indexOfObject:anObject] != NSNotFound);
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (BOOL) isEqual: anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
if ([anObject isKindOf:[NSArray class]])
|
|
|
|
return [self isEqualToArray:anObject];
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isEqualToArray: (NSArray*)otherArray
|
|
|
|
{
|
|
|
|
int i, c = [self count];
|
1995-04-04 16:01:04 +00:00
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
if (c != [otherArray count])
|
1995-04-04 16:01:04 +00:00
|
|
|
return NO;
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
for (i = 0; i < c; i++)
|
1996-03-30 19:14:43 +00:00
|
|
|
if (![[self objectAtIndex: i] isEqual: [otherArray objectAtIndex: i]])
|
1995-04-04 16:01:04 +00:00
|
|
|
return NO;
|
|
|
|
return YES;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- lastObject
|
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int count = [self count];
|
1996-03-30 23:00:27 +00:00
|
|
|
if (count == 0)
|
|
|
|
return nil;
|
|
|
|
return [self objectAtIndex: count-1];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) makeObjectsPerform: (SEL)aSelector
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int i, c = [self count];
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
[[self objectAtIndex:i] perform:aSelector];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) makeObjectsPerform: (SEL)aSelector withObject:argument
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int i, c = [self count];
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
[[self objectAtIndex:i] perform:aSelector withObject:argument];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
1995-04-04 16:01:04 +00:00
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (NSArray*) sortedArrayUsingSelector: (SEL)comparator
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
[self notImplemented:_cmd];
|
|
|
|
return nil;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (NSArray*) sortedArrayUsingFunction: (int(*)(id,id,void*))comparator
|
|
|
|
context: (void*)context
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
[self notImplemented:_cmd];
|
|
|
|
return nil;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (NSString*) componentsJoinedByString: (NSString*)separator
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-04-07 21:01:59 +00:00
|
|
|
int i, c = [self count];
|
|
|
|
id s = [NSMutableString stringWithCapacity:2]; /* arbitrary capacity */
|
|
|
|
|
|
|
|
if (!c)
|
|
|
|
return s;
|
|
|
|
[s appendString:[[self objectAtIndex:0] description]];
|
|
|
|
for (i = 1; i < c; i++)
|
|
|
|
{
|
|
|
|
[s appendString:separator];
|
|
|
|
[s appendString:[[self objectAtIndex:i] description]];
|
|
|
|
}
|
|
|
|
return s;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- firstObjectCommonWithArray: (NSArray*)otherArray
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int i, c = [self count];
|
|
|
|
id o;
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
if ([otherArray containsObject:(o = [self objectAtIndex:i])])
|
|
|
|
return o;
|
|
|
|
return nil;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
1996-03-30 19:14:43 +00:00
|
|
|
- (NSArray*) subarrayWithRange: (NSRange)range
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1996-03-30 19:14:43 +00:00
|
|
|
id na;
|
|
|
|
id *objects;
|
|
|
|
unsigned c = [self count];
|
|
|
|
unsigned i, j, k;
|
|
|
|
|
|
|
|
// If array is empty or start is beyond end of array
|
|
|
|
// then return an empty array
|
|
|
|
if (([self count] == 0) || (range.location > (c-1)))
|
|
|
|
return [NSArray array];
|
|
|
|
|
|
|
|
// Obtain bounds
|
|
|
|
i = range.location;
|
|
|
|
// Check if length extends beyond end of array
|
|
|
|
if ((range.location + range.length) > (c-1))
|
|
|
|
j = c-1;
|
|
|
|
else
|
|
|
|
j = range.location + range.length - 1;
|
|
|
|
|
|
|
|
// Copy the ids from the range into a temporary array
|
|
|
|
OBJC_MALLOC(objects, id, j-i+1);
|
|
|
|
for (k = i; k <= j; k++)
|
|
|
|
objects[k-i] = [self objectAtIndex:k];
|
|
|
|
|
|
|
|
// Create the new array
|
|
|
|
na = [[NSArray alloc] initWithObjects:objects count:j-i+1];
|
|
|
|
OBJC_FREE(objects);
|
|
|
|
return na;
|
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (NSEnumerator*) objectEnumerator
|
|
|
|
{
|
1995-10-30 01:05:15 +00:00
|
|
|
return [[[NSArrayEnumerator alloc] initWithArray:self]
|
|
|
|
autorelease];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
}
|
1995-04-03 22:59:20 +00:00
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (NSEnumerator*) reverseObjectEnumerator
|
|
|
|
{
|
1995-10-30 01:05:15 +00:00
|
|
|
return [[[NSArrayEnumeratorReverse alloc] initWithArray:self]
|
|
|
|
autorelease];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
}
|
1995-04-03 22:59:20 +00:00
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (NSString*) description
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-04-04 16:01:04 +00:00
|
|
|
[self notImplemented:_cmd];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
return nil;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (NSString*) descriptionWithIndent: (unsigned)level
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-04-04 16:01:04 +00:00
|
|
|
[self notImplemented:_cmd];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
return nil;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* The NSCopying Protocol */
|
|
|
|
|
|
|
|
- copyWithZone: (NSZone*)zone
|
|
|
|
{
|
1995-06-30 14:07:44 +00:00
|
|
|
/* a deep copy */
|
|
|
|
int count = [self count];
|
|
|
|
id objects[count];
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
objects[i] = [[self objectAtIndex:i] copyWithZone:zone];
|
|
|
|
return [[[[self class] _concreteClass] allocWithZone:zone]
|
|
|
|
initWithObjects:objects count:count];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The NSMutableCopying Protocol */
|
|
|
|
|
|
|
|
- mutableCopyWithZone: (NSZone*)zone
|
|
|
|
{
|
1995-06-30 14:07:44 +00:00
|
|
|
/* a shallow copy */
|
|
|
|
return [[[[self class] _mutableConcreteClass] allocWithZone:zone]
|
|
|
|
initWithArray:self];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
}
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSMutableArray: NSArray
|
|
|
|
|
1995-05-05 15:50:26 +00:00
|
|
|
+ allocWithZone: (NSZone*)z
|
|
|
|
{
|
1995-06-30 14:07:44 +00:00
|
|
|
return NSAllocateObject([self _mutableConcreteClass], 0, z);
|
1995-05-05 15:50:26 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
+ arrayWithCapacity: (unsigned)numItems
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-11-03 22:22:02 +00:00
|
|
|
return [[[self alloc] initWithCapacity:numItems]
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
autorelease];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* This is the desgnated initializer for NSMutableArray */
|
|
|
|
- initWithCapacity: (unsigned)numItems
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1996-02-01 17:04:17 +00:00
|
|
|
[self subclassResponsibility:_cmd];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
return nil;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
1995-06-30 13:45:13 +00:00
|
|
|
#if 0
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* Not in OpenStep. */
|
|
|
|
- (void) addObjects: (id*)objects count: (unsigned)count
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
|
|
|
}
|
1995-06-30 13:45:13 +00:00
|
|
|
#endif
|
1995-04-03 22:59:20 +00:00
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* Override our superclass's designated initializer to go our's */
|
|
|
|
- initWithObjects: (id*)objects count: (unsigned)count
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* xxx Could be made more efficient by increasing capacity all at once. */
|
|
|
|
int i;
|
|
|
|
self = [self initWithCapacity:count];
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[self addObject:objects[i]];
|
|
|
|
return self;
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) addObject: anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-11-24 20:09:18 +00:00
|
|
|
[self subclassResponsibility:_cmd];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) replaceObjectAtIndex: (unsigned)index withObject: anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-11-24 20:09:18 +00:00
|
|
|
[self subclassResponsibility:_cmd];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) insertObject: anObject atIndex: (unsigned)index
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-11-24 20:09:18 +00:00
|
|
|
[self subclassResponsibility:_cmd];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) removeObjectAtIndex: (unsigned)index
|
1995-04-03 22:59:20 +00:00
|
|
|
{
|
1995-11-24 20:09:18 +00:00
|
|
|
[self subclassResponsibility:_cmd];
|
1995-04-03 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) removeLastObject
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int count = [self count];
|
1996-03-30 23:00:27 +00:00
|
|
|
if (count == 0)
|
|
|
|
[NSException raise: NSRangeException
|
|
|
|
format: @"Trying to remove from an empty array."];
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
[self removeObjectAtIndex:count-1];
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) removeObjectIdenticalTo: anObject
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int i = [self indexOfObjectIdenticalTo:anObject];
|
1996-03-30 19:14:43 +00:00
|
|
|
if (i != NSNotFound)
|
|
|
|
[self removeObjectAtIndex: i];
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) removeObject: anObject
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int i = [self indexOfObject:anObject];
|
1996-03-30 19:14:43 +00:00
|
|
|
if (i != NSNotFound)
|
|
|
|
[self removeObjectAtIndex:i];
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) removeAllObjects
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
1996-03-30 19:14:43 +00:00
|
|
|
while ([self count])
|
|
|
|
[self removeLastObject];
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) addObjectsFromArray: (NSArray*)otherArray
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
/* xxx Could be made more efficient by increasing capacity all at once. */
|
|
|
|
int i, c = [otherArray count];
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
[self addObject:[otherArray objectAtIndex:i]];
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
1996-03-30 19:14:43 +00:00
|
|
|
- (void) setArray:(NSArray *)otherArray
|
|
|
|
{
|
|
|
|
[self removeAllObjects];
|
|
|
|
[self addObjectsFromArray:otherArray];
|
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) removeObjectsFromIndices: (unsigned*)indices
|
|
|
|
numIndices: (unsigned)count
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
int compare_unsigned(const void *u1, const void *u2)
|
|
|
|
{
|
|
|
|
return *((int*)u1) - *((int*)u2);
|
|
|
|
}
|
|
|
|
/* xxx are we allowed to modify the contents of indices? */
|
|
|
|
qsort(indices, count, sizeof(unsigned), compare_unsigned);
|
|
|
|
while (count--)
|
|
|
|
[self removeObjectAtIndex:indices[count]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) removeObjectsInArray: (NSArray*)otherArray
|
|
|
|
{
|
|
|
|
int i, c = [otherArray count];
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
[self removeObject:[otherArray objectAtIndex:i]];
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
(allocWithZone): Removed method.
(arrayWithObjects:, initWithObjects:, initWithArray:, count,
indexOfObjectIdenticalTo:, indexOfObject:, isEqualToArray:,
makeObjectsPerform:, makeObjectsPerform:withObject:, lastObject,
firstObjectCommonWithArray:, arrayWithCapacity:, addObject:,
replaceObjectAtIndex:, removeLastObject, insertObject:atIndex:,
removeObjectAtIndex:, removeObjectIdenticalTo:, removeObject:,
removeAllObjects, addObjectsFromArray:,
removeObjectsFromIndices:numIndices:, removeObjectsInArray:,
copyWithZone:, mutableCopyWithZone:): Newly implemented or majorly
overhauled.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@285 72102866-910b-0410-8b05-ffd578937521
1995-04-05 20:23:03 +00:00
|
|
|
- (void) sortUsingFunction: (int(*)(id,id,void*))compare
|
|
|
|
context: (void*)context
|
1995-04-03 03:18:43 +00:00
|
|
|
{
|
|
|
|
[self notImplemented:_cmd];
|
|
|
|
}
|
|
|
|
|
1994-11-08 16:44:01 +00:00
|
|
|
@end
|