~ubuntu-branches/ubuntu/edgy/sope/edgy

« back to all changes in this revision

Viewing changes to libFoundation/Foundation/NSArray.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Ley
  • Date: 2005-08-19 16:53:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050819165331-hs683wz1osm708pw
Tags: upstream-4.4rc.2
ImportĀ upstreamĀ versionĀ 4.4rc.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
   NSArray.h
 
3
 
 
4
   Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
 
5
   All rights reserved.
 
6
 
 
7
   Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
 
8
 
 
9
   This file is part of libFoundation.
 
10
 
 
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
 
15
   documentation.
 
16
 
 
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.
 
23
*/
 
24
 
 
25
#ifndef __NSArray_h__
 
26
#define __NSArray_h__
 
27
 
 
28
#include <Foundation/NSObject.h>
 
29
#include <Foundation/NSRange.h>
 
30
 
 
31
@class NSString;
 
32
@class NSEnumerator;
 
33
@class NSDictionary;
 
34
@class NSURL;
 
35
 
 
36
@interface NSArray : NSObject <NSCoding, NSCopying, NSMutableCopying>
 
37
 
 
38
/* Allocating and Initializing an Array */
 
39
+ (id)allocWithZone:(NSZone*)zone;
 
40
+ (id)array;
 
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;
 
52
 
 
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;
 
60
- (id)lastObject;
 
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;
 
66
 
 
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;
 
73
 
 
74
/* Comparing Arrays */
 
75
- (id)firstObjectCommonWithArray:(NSArray*)otherArray;
 
76
- (BOOL)isEqualToArray:(NSArray*)otherArray;
 
77
 
 
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;
 
86
 
 
87
/* Joining String Elements */
 
88
- (NSString*)componentsJoinedByString:(NSString*)separator;
 
89
 
 
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;
 
96
 
 
97
/* Write plist to file */
 
98
- (BOOL)writeToFile:(NSString*)fileName atomically:(BOOL)flag;
 
99
 
 
100
/* From adopted/inherited protocols */
 
101
- (unsigned)hash;
 
102
- (BOOL)isEqual:(id)anObject;
 
103
 
 
104
@end
 
105
 
 
106
/*
 
107
 * Extensions to NSArray
 
108
 */
 
109
 
 
110
@interface NSArray (NSArrayExtensions)
 
111
 
 
112
/* Sending Messages to Elements */
 
113
- (void)makeObjectsPerform:(SEL)aSelector
 
114
  withObject:(id)anObject1 withObject:(id)anObject2;
 
115
 
 
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;
 
120
 
 
121
- (NSArray*)arrayWithObjectsThat:(BOOL(*)(id anObject))comparator;
 
122
- (NSArray*)map:(id(*)(id anObject))function
 
123
  objectsThat:(BOOL(*)(id anObject))comparator;
 
124
 
 
125
@end
 
126
 
 
127
/*
 
128
 * NSMutableArray class
 
129
 */
 
130
 
 
131
@interface NSMutableArray : NSArray
 
132
 
 
133
/* Creating and Initializing an NSMutableArray */
 
134
+ (id)allocWithZone:(NSZone*)zone;
 
135
+ (id)arrayWithCapacity:(unsigned int)aNumItems;
 
136
- (id)initWithCapacity:(unsigned int)aNumItems;
 
137
- (id)init;
 
138
 
 
139
/* Adding Objects */
 
140
- (void)addObject:(id)anObject;
 
141
- (void)addObjectsFromArray:(NSArray*)anotherArray;
 
142
- (void)insertObject:(id)anObject atIndex:(unsigned int)index;
 
143
 
 
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;
 
156
 
 
157
/* Sorting */
 
158
- (void)sortUsingFunction:(int (*)(id ,id ,void*))compare
 
159
        context:(void*)context;
 
160
- (void)sortUsingSelector:(SEL)comparator;
 
161
 
 
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;
 
169
 
 
170
@end
 
171
 
 
172
/*
 
173
 * Extensions to NSArray
 
174
 */
 
175
 
 
176
@interface NSMutableArray (NSMutableArrayExtensions)
 
177
 
 
178
/* Removing Objects */
 
179
- (void)removeObjectsFrom:(unsigned int)index count:(unsigned int)count;
 
180
- (void)removeObjectsThat:(BOOL(*)(id anObject))comparator;
 
181
 
 
182
@end
 
183
 
 
184
#endif /* __NSArray_h__ */
 
185
 
 
186
/*
 
187
  Local Variables:
 
188
  c-basic-offset: 4
 
189
  tab-width: 8
 
190
  End:
 
191
*/