16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "config.h"
#include <string.h>
#import "OFMutableArray.h"
#import "OFDataArray.h"
#import "OFExceptions.h"
@implementation OFMutableArray
- copy
{
OFArray *new = [[OFArray alloc] init];
id *objs;
|
>
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "config.h"
#include <string.h>
#import "OFMutableArray.h"
#import "OFDataArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
@implementation OFMutableArray
- copy
{
OFArray *new = [[OFArray alloc] init];
id *objs;
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
initWithDataArray: array
mutationsPointer: &mutations] autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
id *objs = [array cArray];
size_t i, count = [array count];
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < count && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
newWithClass: isa];
block(objs[i], i, &stop);
}
}
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
id *objs = [array cArray];
size_t i, count = [array count];
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < count && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
newWithClass: isa];
id new = block(objs[i], i, &stop);
if (new == nil)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
[new retain];
[objs[i] release];
objs[i] = new;
}
}
#endif
@end
|
>
>
>
>
>
|
>
>
>
>
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
initWithDataArray: array
mutationsPointer: &mutations] autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
id *objs = [array cArray];
size_t i, count = [array count];
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < count && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
newWithClass: isa];
block(objs[i], i, &stop);
[pool releaseObjects];
}
[pool release];
}
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
id *objs = [array cArray];
size_t i, count = [array count];
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < count && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
newWithClass: isa];
id new = block(objs[i], i, &stop);
if (new == nil)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
[new retain];
[objs[i] release];
objs[i] = new;
[pool releaseObjects];
}
[pool release];
}
#endif
@end
|