ObjFW  Check-in [13e6e99067]

Overview
Comment:swapObjectAtIndex... -> exchangeObjectAtIndex...

For consistency with Foundation.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 13e6e99067aa84dca79c180d92cdf741e4803d114e6225fb1f7d344740505893
User & Date: js on 2012-06-06 12:15:40
Other Links: manifest | tags
Context
2012-06-06
12:15
-[addObject:atIndex:] -> -[insertObject:atIndex:]. check-in: 26f2ffa908 user: js tags: trunk
12:15
swapObjectAtIndex... -> exchangeObjectAtIndex... check-in: 13e6e99067 user: js tags: trunk
2012-06-05
16:05
Disallow newlines in JSON strings. check-in: 670a739c02 user: js tags: trunk
Changes

Modified src/OFMutableArray.h from [7429d32994] to [0c1ac94dc7].

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
 *
 * \param block The block which returns a new object for each object
 */
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block;
#endif

/**
 * \brief Swaps the objects at the specified indices.
 *
 * \param index1 The index of the first object to swap
 * \param index2 The index of the second object to swap
 */
- (void)swapObjectAtIndex: (size_t)index1
	withObjectAtIndex: (size_t)index2;

/**
 * \brief Sorts the array.
 */
- (void)sort;

/**







|

|
|

|
|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
 *
 * \param block The block which returns a new object for each object
 */
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block;
#endif

/**
 * \brief Exchange the objects at the specified indices.
 *
 * \param index1 The index of the first object to exchange
 * \param index2 The index of the second object to exchange
 */
- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2;

/**
 * \brief Sorts the array.
 */
- (void)sort;

/**

Modified src/OFMutableArray.m from [833d3b17ca] to [aaf401cec7].

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
			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







|
|



|
|







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
			i++;

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

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

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

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

@implementation OFMutableArray_placeholder
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
	    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







|
|







295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
	    BOOL *stop) {
		[self replaceObjectAtIndex: index
				withObject: block(object, index, stop)];
	}];
}
#endif

- (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
{
	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







|
|






330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
{
	size_t i, j, count = [self count];

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

	for (i = 0, j = count - 1; i < j; i++, j--)
		[self exchangeObjectAtIndex: i
			  withObjectAtIndex: j];
}

- (void)makeImmutable
{
}
@end

Modified src/OFMutableArray_adjacent.m from [a923c5af53] to [998a7318fe].

208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
	id object = [self objectAtIndex: [array count] - 1];
	[array removeLastItem];
	[object release];

	mutations++;
}

- (void)swapObjectAtIndex: (size_t)index1
	withObjectAtIndex: (size_t)index2
{
	id *objects = [array cArray];
	size_t count = [array count];
	id tmp;

	if (index1 >= count || index2 >= count)
		@throw [OFOutOfRangeException exceptionWithClass: isa];







|
|







208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
	id object = [self objectAtIndex: [array count] - 1];
	[array removeLastItem];
	[object release];

	mutations++;
}

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{
	id *objects = [array cArray];
	size_t count = [array count];
	id tmp;

	if (index1 >= count || index2 >= count)
		@throw [OFOutOfRangeException exceptionWithClass: isa];