ObjFW  Check-in [26f2ffa908]

Overview
Comment:-[addObject:atIndex:] -> -[insertObject:atIndex:].

For consistency with Foundation.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 26f2ffa9084bcb98d90aa304e5acb19a588d0d86fe21119bd6a704746445d70e
User & Date: js on 2012-06-06 12:15:46
Other Links: manifest | tags
Context
2012-06-06
12:23
Add a missing check in OFDataArray. check-in: e68229ff3b user: js tags: trunk
12:15
-[addObject:atIndex:] -> -[insertObject:atIndex:]. check-in: 26f2ffa908 user: js tags: trunk
12:15
swapObjectAtIndex... -> exchangeObjectAtIndex... check-in: 13e6e99067 user: js tags: trunk
Changes

Modified src/OFMutableArray.h from [0c1ac94dc7] to [1edd47fa69].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 * \brief Adds an object to the OFArray.
 *
 * \param object An object to add
 */
- (void)addObject: (id)object;

/**
 * \brief Adds an object to the OFArray at the specified index.
 *
 * \param object An object to add
 * \param index The index where the object should be added
 */
- (void)addObject: (id)object
	  atIndex: (size_t)index;

/**
 * \brief Replaces the first object equivalent to the specified object with the
 *	  other specified object.
 *
 * \param oldObject The object to replace
 * \param newObject The replacement object







|




|
|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 * \brief Adds an object to the OFArray.
 *
 * \param object An object to add
 */
- (void)addObject: (id)object;

/**
 * \brief Inserts an object to the OFArray at the specified index.
 *
 * \param object An object to add
 * \param index The index where the object should be added
 */
- (void)insertObject: (id)object
	     atIndex: (size_t)index;

/**
 * \brief Replaces the first object equivalent to the specified object with the
 *	  other specified object.
 *
 * \param oldObject The object to replace
 * \param newObject The replacement object

Modified src/OFMutableArray.m from [aaf401cec7] to [e6d36fbf2d].

173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
- copy
{
	return [[OFArray alloc] initWithArray: self];
}

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

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

- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object







|
|


|
|







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
- copy
{
	return [[OFArray alloc] initWithArray: self];
}

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

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

- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object

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

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
	[array addItem: &object];
	[object retain];

	mutations++;
}

- (void)addObject: (id)object
	  atIndex: (size_t)index
{
	[array addItem: &object
	       atIndex: index];
	[object retain];

	mutations++;
}







|
|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
	[array addItem: &object];
	[object retain];

	mutations++;
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
{
	[array addItem: &object
	       atIndex: index];
	[object retain];

	mutations++;
}

Modified tests/OFArrayTests.m from [19f0fe9122] to [1073eae76a].

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

	TEST(@"-[description]",
	    [[a[0] description ]isEqual: @"(\n\tFoo,\n\tBar,\n\tBaz\n)"])

	TEST(@"-[addObject:]", R([m[0] addObject: c_ary[0]]) &&
	    R([m[0] addObject: c_ary[2]]))

	TEST(@"-[addObject:atIndex:]", R([m[0] addObject: c_ary[1]
						 atIndex: 1]))

	TEST(@"-[count]", [m[0] count] == 3 && [a[0] count] == 3 &&
	    [a[1] count] == 3)

	TEST(@"-[isEqual:]", [m[0] isEqual: a[0]] && [a[0] isEqual: a[1]])

	TEST(@"-[objectAtIndex:]",







|
|







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

	TEST(@"-[description]",
	    [[a[0] description ]isEqual: @"(\n\tFoo,\n\tBar,\n\tBaz\n)"])

	TEST(@"-[addObject:]", R([m[0] addObject: c_ary[0]]) &&
	    R([m[0] addObject: c_ary[2]]))

	TEST(@"-[insertObject:atIndex:]", R([m[0] insertObject: c_ary[1]
						       atIndex: 1]))

	TEST(@"-[count]", [m[0] count] == 3 && [a[0] count] == 3 &&
	    [a[1] count] == 3)

	TEST(@"-[isEqual:]", [m[0] isEqual: a[0]] && [a[0] isEqual: a[1]])

	TEST(@"-[objectAtIndex:]",