4
Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
7
Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
9
This file is part of libFoundation.
11
Permission to use, copy, modify, and distribute this software and its
12
documentation for any purpose and without fee is hereby granted, provided
13
that the above copyright notice appear in all copies and that both that
14
copyright notice and this permission notice appear in supporting
17
We disclaim all warranties with regard to this software, including all
18
implied warranties of merchantability and fitness, in no event shall
19
we be liable for any special, indirect or consequential damages or any
20
damages whatsoever resulting from loss of use, data or profits, whether in
21
an action of contract, negligence or other tortious action, arising out of
22
or in connection with the use or performance of this software.
28
#include <Foundation/NSObject.h>
29
#include <Foundation/NSRange.h>
36
@interface NSArray : NSObject <NSCoding, NSCopying, NSMutableCopying>
38
/* Allocating and Initializing an Array */
39
+ (id)allocWithZone:(NSZone*)zone;
41
+ (id)arrayWithObject:(id)anObject;
42
+ (id)arrayWithObjects:(id)firstObj,...;
43
+ (id)arrayWithArray:(NSArray*)anotherArray;
44
+ (id)arrayWithContentsOfFile:(NSString *)fileName;
45
+ (id)arrayWithContentsOfURL:(NSURL *)_url;
46
+ (id)arrayWithObjects:(id*)objects count:(unsigned int)count;
47
- (id)initWithArray:(NSArray*)anotherArray;
48
- (id)initWithArray:(NSArray*)anotherArray copyItems:(BOOL)flag;
49
- (id)initWithObjects:(id)firstObj,...;
50
- (id)initWithObjects:(id *)objects count:(unsigned int)count;
51
- (id)initWithContentsOfURL:(NSURL *)_url;
53
/* Querying the Array */
54
- (BOOL)containsObject:(id)anObject;
55
- (unsigned int)count;
56
- (unsigned int)indexOfObject:(id)anObject;
57
- (unsigned int)indexOfObjectIdenticalTo:(id)anObject;
58
- (unsigned int)indexOfObject:(id)anObject inRange:(NSRange)aRange;
59
- (unsigned int)indexOfObjectIdenticalTo:(id)anObject inRange:(NSRange)aRange;
61
- (id)objectAtIndex:(unsigned int)index;
62
- (void)getObjects:(id *)buffer;
63
- (void)getObjects:(id *)buffer range:(NSRange)range;
64
- (NSEnumerator*)objectEnumerator;
65
- (NSEnumerator*)reverseObjectEnumerator;
67
/* Sending Messages to Elements */
68
- (void)makeObjectsPerformSelector:(SEL)aSelector;
69
- (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject;
70
/* Obsolete messages */
71
- (void)makeObjectsPerform:(SEL)aSelector;
72
- (void)makeObjectsPerform:(SEL)aSelector withObject:(id)anObject;
74
/* Comparing Arrays */
75
- (id)firstObjectCommonWithArray:(NSArray*)otherArray;
76
- (BOOL)isEqualToArray:(NSArray*)otherArray;
78
/* Deriving New Array */
79
- (NSArray*)arrayByAddingObject:(id)anObject;
80
- (NSArray*)arrayByAddingObjectsFromArray:(NSArray*)anotherArray;
81
- (NSArray*)sortedArrayUsingFunction:
82
(int(*)(id element1, id element2, void *userData))comparator
83
context:(void*)context;
84
- (NSArray*)sortedArrayUsingSelector:(SEL)comparator;
85
- (NSArray*)subarrayWithRange:(NSRange)range;
87
/* Joining String Elements */
88
- (NSString*)componentsJoinedByString:(NSString*)separator;
90
/* Creating a String Description of the Array */
91
- (NSString*)description;
92
- (NSString*)stringRepresentation;
93
- (NSString*)descriptionWithLocale:(NSDictionary*)locale;
94
- (NSString*)descriptionWithLocale:(NSDictionary*)locale
95
indent:(unsigned int)level;
97
/* Write plist to file */
98
- (BOOL)writeToFile:(NSString*)fileName atomically:(BOOL)flag;
100
/* From adopted/inherited protocols */
102
- (BOOL)isEqual:(id)anObject;
107
* Extensions to NSArray
110
@interface NSArray (NSArrayExtensions)
112
/* Sending Messages to Elements */
113
- (void)makeObjectsPerform:(SEL)aSelector
114
withObject:(id)anObject1 withObject:(id)anObject2;
116
/* Deriving New Arrays */
117
- (NSArray*)map:(SEL)aSelector;
118
- (NSArray*)map:(SEL)aSelector with:anObject;
119
- (NSArray*)map:(SEL)aSelector with:anObject with:otherObject;
121
- (NSArray*)arrayWithObjectsThat:(BOOL(*)(id anObject))comparator;
122
- (NSArray*)map:(id(*)(id anObject))function
123
objectsThat:(BOOL(*)(id anObject))comparator;
128
* NSMutableArray class
131
@interface NSMutableArray : NSArray
133
/* Creating and Initializing an NSMutableArray */
134
+ (id)allocWithZone:(NSZone*)zone;
135
+ (id)arrayWithCapacity:(unsigned int)aNumItems;
136
- (id)initWithCapacity:(unsigned int)aNumItems;
140
- (void)addObject:(id)anObject;
141
- (void)addObjectsFromArray:(NSArray*)anotherArray;
142
- (void)insertObject:(id)anObject atIndex:(unsigned int)index;
144
/* Removing Objects */
145
- (void)removeAllObjects;
146
- (void)removeLastObject;
147
- (void)removeObject:(id)anObject;
148
- (void)removeObjectAtIndex:(unsigned int)index;
149
- (void)removeObjectIdenticalTo:(id)anObject;
150
- (void)removeObjectsFromIndices:(unsigned int*)indices
151
numIndices:(unsigned int)count;
152
- (void)removeObjectsInArray:(NSArray*)otherArray;
153
- (void)removeObject:(id)anObject inRange:(NSRange)aRange;
154
- (void)removeObjectIdenticalTo:(id)anObject inRange:(NSRange)aRange;
155
- (void)removeObjectsInRange:(NSRange)aRange;
158
- (void)sortUsingFunction:(int (*)(id ,id ,void*))compare
159
context:(void*)context;
160
- (void)sortUsingSelector:(SEL)comparator;
162
/* Replacing Objects */
163
- (void)replaceObjectAtIndex:(unsigned int)index withObject:(id)anObject;
164
- (void)replaceObjectsInRange:(NSRange)rRange
165
withObjectsFromArray:(NSArray*)anArray;
166
- (void)replaceObjectsInRange:(NSRange)rRange
167
withObjectsFromArray:(NSArray*)anArray range:(NSRange)aRange;
168
- (void)setArray:(NSArray*)otherArray;
173
* Extensions to NSArray
176
@interface NSMutableArray (NSMutableArrayExtensions)
178
/* Removing Objects */
179
- (void)removeObjectsFrom:(unsigned int)index count:(unsigned int)count;
180
- (void)removeObjectsThat:(BOOL(*)(id anObject))comparator;
184
#endif /* __NSArray_h__ */