1995-03-18 17:15:15 +00:00
|
|
|
|
/* Interface for NSArray for GNUStep
|
1996-03-30 22:20:26 +00:00
|
|
|
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
1995-07-01 18:34:58 +00:00
|
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1996-03-31 22:14:35 +00:00
|
|
|
|
Created: 1995
|
1995-03-18 17:15:15 +00:00
|
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
|
This file is part of the GNUstep Base Library.
|
1995-03-18 17:15:15 +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
|
1995-04-03 22:59:20 +00:00
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
|
License along with this library; if not, write to the Free
|
1999-09-09 02:56:20 +00:00
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
1995-04-03 22:59:20 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
|
#ifndef __NSArray_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
#define __NSArray_h_GNUSTEP_BASE_INCLUDE
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
1995-04-17 21:13:20 +00:00
|
|
|
|
#include <Foundation/NSRange.h>
|
|
|
|
|
#include <Foundation/NSUtilities.h>
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
|
|
|
|
@class NSString;
|
2001-07-16 07:08:47 +00:00
|
|
|
|
@class NSURL;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
1998-08-01 21:27:26 +00:00
|
|
|
|
@interface NSArray : NSObject <NSCoding, NSCopying, NSMutableCopying>
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
+ (id) array;
|
|
|
|
|
+ (id) arrayWithArray: (NSArray*)array;
|
|
|
|
|
+ (id) arrayWithContentsOfFile: (NSString*)file;
|
2003-07-15 16:35:11 +00:00
|
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
|
+ (id) arrayWithContentsOfURL: (NSURL*)aURL;
|
|
|
|
|
#endif
|
1999-09-16 07:21:34 +00:00
|
|
|
|
+ (id) arrayWithObject: (id)anObject;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
+ (id) arrayWithObjects: (id)firstObject, ...;
|
1999-09-16 07:21:34 +00:00
|
|
|
|
+ (id) arrayWithObjects: (id*)objects count: (unsigned)count;
|
2001-01-08 16:45:36 +00:00
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (NSArray*) arrayByAddingObject: (id)anObject;
|
1996-03-30 22:20:26 +00:00
|
|
|
|
- (NSArray*) arrayByAddingObjectsFromArray: (NSArray*)anotherArray;
|
1995-04-05 20:26:11 +00:00
|
|
|
|
- (BOOL) containsObject: anObject;
|
2001-01-08 16:45:36 +00:00
|
|
|
|
- (unsigned) count; // Primitive
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) getObjects: (id*)aBuffer;
|
|
|
|
|
- (void) getObjects: (id*)aBuffer range: (NSRange)aRange;
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (unsigned) indexOfObject: (id)anObject;
|
|
|
|
|
- (unsigned) indexOfObject: (id)anObject inRange: (NSRange)aRange;
|
|
|
|
|
- (unsigned) indexOfObjectIdenticalTo: (id)anObject;
|
|
|
|
|
- (unsigned) indexOfObjectIdenticalTo: (id)anObject inRange: (NSRange)aRange;
|
2001-01-08 16:45:36 +00:00
|
|
|
|
- (id) initWithArray: (NSArray*)array;
|
2002-08-27 09:37:58 +00:00
|
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
|
- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy;
|
|
|
|
|
#endif
|
2001-01-08 16:45:36 +00:00
|
|
|
|
- (id) initWithContentsOfFile: (NSString*)file;
|
2003-07-15 16:35:11 +00:00
|
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
|
- (id) initWithContentsOfURL: (NSURL*)aURL;
|
|
|
|
|
#endif
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (id) initWithObjects: firstObject, ...;
|
2001-01-08 16:45:36 +00:00
|
|
|
|
- (id) initWithObjects: (id*)objects count: (unsigned)count; // Primitive
|
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (id) lastObject;
|
2001-01-08 16:45:36 +00:00
|
|
|
|
- (id) objectAtIndex: (unsigned)index; // Primitive
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (id) firstObjectCommonWithArray: (NSArray*)otherArray;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
- (BOOL) isEqualToArray: (NSArray*)otherArray;
|
|
|
|
|
|
1998-11-10 20:16:33 +00:00
|
|
|
|
#ifndef STRICT_MACOS_X
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) makeObjectsPerform: (SEL)aSelector;
|
|
|
|
|
- (void) makeObjectsPerform: (SEL)aSelector withObject: (id)argument;
|
1998-11-10 20:16:33 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifndef STRICT_OPENSTEP
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) makeObjectsPerformSelector: (SEL)aSelector;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) makeObjectsPerformSelector: (SEL)aSelector withObject: (id)arg;
|
1998-11-10 20:16:33 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1998-01-19 15:20:15 +00:00
|
|
|
|
- (NSData*) sortedArrayHint;
|
2003-02-19 17:48:54 +00:00
|
|
|
|
- (NSArray*) sortedArrayUsingFunction: (NSComparisonResult (*)(id, id, void*))comparator
|
1998-01-19 15:20:15 +00:00
|
|
|
|
context: (void*)context;
|
2003-02-19 18:42:42 +00:00
|
|
|
|
- (NSArray*) sortedArrayUsingFunction: (NSComparisonResult (*)(id, id, void*))comparator
|
1998-01-19 15:20:15 +00:00
|
|
|
|
context: (void*)context
|
|
|
|
|
hint: (NSData*)hint;
|
|
|
|
|
- (NSArray*) sortedArrayUsingSelector: (SEL)comparator;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (NSArray*) subarrayWithRange: (NSRange)aRange;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
|
1995-04-05 20:26:11 +00:00
|
|
|
|
- (NSString*) componentsJoinedByString: (NSString*)separator;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
- (NSArray*) pathsMatchingExtensions: (NSArray*)extensions;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (NSEnumerator*) objectEnumerator;
|
1995-04-05 20:26:11 +00:00
|
|
|
|
- (NSEnumerator*) reverseObjectEnumerator;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
|
1995-04-05 20:26:11 +00:00
|
|
|
|
- (NSString*) description;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
- (NSString*) descriptionWithLocale: (NSDictionary*)locale;
|
|
|
|
|
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
|
|
|
|
|
indent: (unsigned int)level;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
2002-03-21 09:45:30 +00:00
|
|
|
|
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
|
2001-07-16 07:08:47 +00:00
|
|
|
|
#ifndef STRICT_OPENSTEP
|
2002-03-21 09:45:30 +00:00
|
|
|
|
- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile;
|
2004-01-06 19:43:29 +00:00
|
|
|
|
- (id) valueForKey: (NSString*)key;
|
2001-07-16 07:08:47 +00:00
|
|
|
|
#endif
|
1995-04-03 22:59:20 +00:00
|
|
|
|
@end
|
|
|
|
|
|
1996-03-31 22:14:35 +00:00
|
|
|
|
|
|
|
|
|
@interface NSMutableArray : NSArray
|
|
|
|
|
|
1999-09-16 07:21:34 +00:00
|
|
|
|
+ (id) arrayWithCapacity: (unsigned)numItems;
|
1996-03-31 22:14:35 +00:00
|
|
|
|
|
2001-01-08 16:45:36 +00:00
|
|
|
|
- (void) addObject: (id)anObject; // Primitive
|
1998-01-19 15:20:15 +00:00
|
|
|
|
- (void) addObjectsFromArray: (NSArray*)otherArray;
|
2002-08-27 11:09:12 +00:00
|
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
|
- (void) exchangeObjectAtIndex: (unsigned int)i1
|
|
|
|
|
withObjectAtIndex: (unsigned int)i2;
|
|
|
|
|
#endif
|
2001-01-08 16:45:36 +00:00
|
|
|
|
- (id) initWithCapacity: (unsigned)numItems; // Primitive
|
|
|
|
|
- (void) insertObject: (id)anObject atIndex: (unsigned)index; // Primitive
|
|
|
|
|
- (void) removeObjectAtIndex: (unsigned)index; // Primitive
|
|
|
|
|
- (void) replaceObjectAtIndex: (unsigned)index
|
|
|
|
|
withObject: (id)anObject; // Primitive
|
1998-01-19 15:20:15 +00:00
|
|
|
|
- (void) replaceObjectsInRange: (NSRange)aRange
|
|
|
|
|
withObjectsFromArray: (NSArray*)anArray;
|
|
|
|
|
- (void) replaceObjectsInRange: (NSRange)aRange
|
|
|
|
|
withObjectsFromArray: (NSArray*)anArray
|
|
|
|
|
range: (NSRange)anotherRange;
|
|
|
|
|
- (void) setArray: (NSArray *)otherArray;
|
|
|
|
|
|
|
|
|
|
- (void) removeAllObjects;
|
1996-03-31 22:14:35 +00:00
|
|
|
|
- (void) removeLastObject;
|
1999-09-16 07:21:34 +00:00
|
|
|
|
- (void) removeObject: (id)anObject;
|
|
|
|
|
- (void) removeObject: (id)anObject inRange: (NSRange)aRange;
|
|
|
|
|
- (void) removeObjectIdenticalTo: (id)anObject;
|
|
|
|
|
- (void) removeObjectIdenticalTo: (id)anObject inRange: (NSRange)aRange;
|
1995-04-05 20:26:11 +00:00
|
|
|
|
- (void) removeObjectsInArray: (NSArray*)otherArray;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
- (void) removeObjectsInRange: (NSRange)aRange;
|
|
|
|
|
- (void) removeObjectsFromIndices: (unsigned*)indices
|
|
|
|
|
numIndices: (unsigned)count;
|
|
|
|
|
|
2003-02-19 18:42:42 +00:00
|
|
|
|
- (void) sortUsingFunction: (NSComparisonResult (*)(id,id,void*))compare
|
1998-01-19 15:20:15 +00:00
|
|
|
|
context: (void*)context;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) sortUsingSelector: (SEL)comparator;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
2004-01-06 19:43:29 +00:00
|
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
|
- (void) setValue: (id)value forKey: (NSString*)key;
|
|
|
|
|
#endif
|
|
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2000-08-07 22:00:31 +00:00
|
|
|
|
@interface NSArray (GNUstep)
|
|
|
|
|
/*
|
|
|
|
|
* Extension methods for working with sorted arrays - use a binary chop
|
|
|
|
|
* to determine the insertion location for an nobject. If equal objects
|
|
|
|
|
* already exist in the array, they will be located immediately before
|
|
|
|
|
* the insertion position.
|
|
|
|
|
*
|
|
|
|
|
* The comparator function takes two items as arguments, the first is the
|
|
|
|
|
* item to be added, the second is the item already in the array.
|
|
|
|
|
* The function should return NSOrderedAscending if the item to be
|
|
|
|
|
* added is 'less than' the item in the array, NSOrderedDescending
|
|
|
|
|
* if it is greater, and NSOrderedSame if it is equal.
|
|
|
|
|
*
|
|
|
|
|
* The selector version works the same - returning NSOrderedAscending if
|
|
|
|
|
* the reciever is 'less than' the item in the array.
|
|
|
|
|
*/
|
|
|
|
|
- (unsigned) insertionPosition: (id)item
|
2002-02-22 04:47:36 +00:00
|
|
|
|
usingFunction: (NSComparisonResult (*)(id, id, void *))sorter
|
|
|
|
|
context: (void *)context;
|
2000-08-07 22:00:31 +00:00
|
|
|
|
- (unsigned) insertionPosition: (id)item
|
|
|
|
|
usingSelector: (SEL)comp;
|
|
|
|
|
@end
|
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
|
#endif /* __NSArray_h_GNUSTEP_BASE_INCLUDE */
|