251
252
253
254
255
256
257
258
259
260
261
262
|
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
BOOL *stop) {
[self replaceObjectAtIndex: index
withObject: block(object, index, stop)];
}];
}
#endif
- (void)makeImmutable
{
}
@end
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
|
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
BOOL *stop) {
[self replaceObjectAtIndex: index
withObject: block(object, index, stop)];
}];
}
#endif
- (void)swapObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2
{
id object1 = [self objectAtIndex: index1];
id object2 = [self objectAtIndex: index2];
[object1 retain];
@try {
[self replaceObjectAtIndex: index1
withObject: object2];
[self replaceObjectAtIndex: index2
withObject: object1];
} @finally {
[object1 release];
}
}
- (void)reverse
{
size_t i, j, count = [self count];
if (count == 0 || count == 1)
return;
for (i = 0, j = count - 1; i < j; i++, j--)
[self swapObjectAtIndex: i
withObjectAtIndex: j];
}
- (void)makeImmutable
{
}
@end
|