ObjFW  Diff

Differences From Artifact [833d3b17ca]:

To Artifact [2fdb683912]:


13
14
15
16
17
18
19


20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28







+
+







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <string.h>

#include <assert.h>

#import "OFMutableArray.h"
#import "OFMutableArray_adjacent.h"
#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
55
56
57
58
59
60
61
62
63


64
65
66
67
68


69
70
71
72
73
74
75
57
58
59
60
61
62
63


64
65
66
67
68


69
70
71
72
73
74
75
76
77







-
-
+
+



-
-
+
+







			i++;

		while ([[array objectAtIndex: j] compare: pivot] !=
		    OF_ORDERED_ASCENDING && j > left)
			j--;

		if (i < j)
			[array swapObjectAtIndex: i
			       withObjectAtIndex: j];
			[array exchangeObjectAtIndex: i
				   withObjectAtIndex: j];
	} while (i < j);

	if ([[array objectAtIndex: i] compare: pivot] == OF_ORDERED_DESCENDING)
		[array swapObjectAtIndex: i
		       withObjectAtIndex: right];
		[array exchangeObjectAtIndex: i
			   withObjectAtIndex: right];

	if (i > 0)
		quicksort(array, left, i - 1);
	quicksort(array, i + 1, right);
}

@implementation OFMutableArray_placeholder
173
174
175
176
177
178
179
180
181


182
183
184
185


186
187
188
189
190
191
192
175
176
177
178
179
180
181


182
183
184
185


186
187
188
189
190
191
192
193
194







-
-
+
+


-
-
+
+







- copy
{
	return [[OFArray alloc] initWithArray: self];
}

- (void)addObject: (id)object
{
	[self addObject: object
		atIndex: [self count]];
	[self insertObject: object
		   atIndex: [self count]];
}

- (void)addObject: (id)object
	  atIndex: (size_t)index
- (void)insertObject: (id)object
	     atIndex: (size_t)index
{
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object
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
292
293
294
295
296
297
298
299
300
301
302
303


304
305
306
307
308
309
310
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
292
293
294
295
296
297
298
299


300
301
302
303
304
305
306
307
308







-
-
-
-
-
-
-










+
+
+
-
+




-
+













-
-
+
+







			[self removeObjectAtIndex: i];

			return;
		}
	}
}

- (void)removeNObjects: (size_t)nObjects
{
	size_t count = [self count];

	[self removeObjectsInRange: of_range(count - nObjects, nObjects)];
}

- (void)removeObjectsInRange: (of_range_t)range
{
	size_t i;

	for (i = 0; i < range.length; i++)
		[self removeObjectAtIndex: range.start];
}

- (void)removeLastObject
{
	size_t count = [self count];

	if (count > 0)
	[self removeNObjects: 1];
		[self removeObjectAtIndex: count - 1];
}

- (void)removeAllObjects
{
	[self removeNObjects: [self count]];
	[self removeObjectsInRange: of_range(0, [self count])];
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	[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
- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{
	id object1 = [self objectAtIndex: index1];
	id object2 = [self objectAtIndex: index2];

	[object1 retain];
	@try {
		[self replaceObjectAtIndex: index1
330
331
332
333
334
335
336
337
338


339
340
341
342
343
344
328
329
330
331
332
333
334


335
336
337
338
339
340
341
342







-
-
+
+






{
	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];
		[self exchangeObjectAtIndex: i
			  withObjectAtIndex: j];
}

- (void)makeImmutable
{
}
@end