ObjFW  Diff

Differences From Artifact [20b125814d]:

To Artifact [fdde418d40]:


31
32
33
34
35
36
37




































38
39
40
41
42
43
44
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








static struct {
	Class isa;
} placeholder;

@interface OFMutableArray_placeholder: OFMutableArray
@end

static void
quicksort(OFMutableArray *array, size_t left, size_t right)
{
	size_t i, j;
	id pivot;

	if (left >= right)
		return;

	i = left;
	j = right - 1;
	pivot = [array objectAtIndex: right];

	do {
		while ([[array objectAtIndex: i] compare: pivot] !=
		    OF_ORDERED_DESCENDING && i < right)
			i++;

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

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

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

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

@implementation OFMutableArray_placeholder
- init
{
	return (id)[[OFMutableArray_adjacent alloc] init];
}

268
269
270
271
272
273
274










275
276
277
278
279
280
281
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327







+
+
+
+
+
+
+
+
+
+







				withObject: object2];
		[self replaceObjectAtIndex: index2
				withObject: object1];
	} @finally {
		[object1 release];
	}
}

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

	if (count == 0 || count == 1)
		return;

	quicksort(self, 0, count - 1);
}

- (void)reverse
{
	size_t i, j, count = [self count];

	if (count == 0 || count == 1)
		return;