ObjFW  Check-in [806b5b24db]

Overview
Comment:Add -[addObject:atIndex:] to OFArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 806b5b24db65f5dae12c64a580725410f2512385d3fb70622b480818500e1794
User & Date: js on 2009-12-02 09:38:32
Other Links: manifest | tags
Context
2009-12-02
09:45
Fix one more missing LD = ${OBJC}. check-in: 25d8c4c030 user: js tags: trunk
09:38
Add -[addObject:atIndex:] to OFArray. check-in: 806b5b24db user: js tags: trunk
09:29
Add -[addNItems:fromCArray:atIndex:] to OFDataArray. check-in: 806550f7ed user: js tags: trunk
Changes

Modified src/OFArray.h from [dcab32a464] to [03634b7b64].

123
124
125
126
127
128
129


130
131
132
133
134
135
136
137
138

/**
 * \return The last object of the OFArray or nil
 */
- (id)lastObject;

- addObject: (OFObject*)obj;


- removeObject: (id)obj;
- removeObjectIdenticalTo: (id)obj;
- removeObjectAtIndex: (size_t)index;
- removeNObjects: (size_t)nobjects;
- removeNObjects: (size_t)nobjects
	 atIndex: (size_t)index;
@end

#import "OFMutableArray.h"







>
>









123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

/**
 * \return The last object of the OFArray or nil
 */
- (id)lastObject;

- addObject: (OFObject*)obj;
- addObject: (OFObject*)obj
    atIndex: (size_t)index;
- removeObject: (id)obj;
- removeObjectIdenticalTo: (id)obj;
- removeObjectAtIndex: (size_t)index;
- removeNObjects: (size_t)nobjects;
- removeNObjects: (size_t)nobjects
	 atIndex: (size_t)index;
@end

#import "OFMutableArray.h"

Modified src/OFArray.m from [da98a6238c] to [bf2f167ef1].

272
273
274
275
276
277
278







279
280
281
282
283
284
285

	[array release];

	[super dealloc];
}

- addObject: (OFObject*)obj







{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- removeObject: (id)obj
{







>
>
>
>
>
>
>







272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292

	[array release];

	[super dealloc];
}

- addObject: (OFObject*)obj
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- addObject: (OFObject*)obj
    atIndex: (size_t)index
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- removeObject: (id)obj
{

Modified src/OFMutableArray.h from [426beeceb7] to [ab1b1cb945].

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









26
27
28
29
30
31
32

/**
 * The OFMutableArray class provides a class for storing, adding and removing
 * objects in an array.
 */
@interface OFMutableArray: OFArray {}
/**
 * Adds an object to the OFDataArray.
 *
 * \param obj An object to add
 */
- addObject: (OFObject*)obj;










/**
 * Removes the first object equivalent to the specified object.
 *
 * \param obj The object to remove
 */
- removeObject: (id)obj;








|





>
>
>
>
>
>
>
>
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

/**
 * The OFMutableArray class provides a class for storing, adding and removing
 * objects in an array.
 */
@interface OFMutableArray: OFArray {}
/**
 * Adds an object to the OFArray.
 *
 * \param obj An object to add
 */
- addObject: (OFObject*)obj;

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

/**
 * Removes the first object equivalent to the specified object.
 *
 * \param obj The object to remove
 */
- removeObject: (id)obj;

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 * Removes the object at the specified index.
 *
 * \param index The index of the object to remove
 */
- removeObjectAtIndex: (size_t)index;

/**
 * Removes the specified amount of objects from the end of the OFDataArray.
 *
 * \param nobjects The number of objects to remove
 */
- removeNObjects: (size_t)nobjects;

/**
 * Removes the specified amount of objects at the specified index.







|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 * Removes the object at the specified index.
 *
 * \param index The index of the object to remove
 */
- removeObjectAtIndex: (size_t)index;

/**
 * Removes the specified amount of objects from the end of the OFArray.
 *
 * \param nobjects The number of objects to remove
 */
- removeNObjects: (size_t)nobjects;

/**
 * Removes the specified amount of objects at the specified index.

Modified src/OFMutableArray.m from [0fbd60e094] to [44d3bbcada].

34
35
36
37
38
39
40










41
42
43
44
45
46
47
}

- addObject: (OFObject*)obj
{
	[array addItem: &obj];
	[obj retain];











	return self;
}

- removeObject: (id)obj
{
	OFObject **objs = [array cArray];
	size_t i, count = [array count];







>
>
>
>
>
>
>
>
>
>







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
}

- addObject: (OFObject*)obj
{
	[array addItem: &obj];
	[obj retain];

	return self;
}

- addObject: (OFObject*)obj
    atIndex: (size_t)index
{
	[array addItem: &obj
	       atIndex: index];
	[obj retain];

	return self;
}

- removeObject: (id)obj
{
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

Modified tests/OFArray.m from [f5ad1e0874] to [f0cc929efd].

36
37
38
39
40
41
42
43



44
45
46
47
48
49
50

	TEST(@"+[arrayWithObjects:]",
	    (a[1] = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]))

	TEST(@"+[arrayWithCArray:]", (a[2] = [OFArray arrayWithCArray: c_ary]))

	TEST(@"-[addObject:]", [a[0] addObject: c_ary[0]] &&
	    [a[0] addObject: c_ary[1]] && [a[0] addObject: c_ary[2]])




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

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

	TEST(@"-[objectAtIndex:]",







|
>
>
>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

	TEST(@"+[arrayWithObjects:]",
	    (a[1] = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]))

	TEST(@"+[arrayWithCArray:]", (a[2] = [OFArray arrayWithCArray: c_ary]))

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

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

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

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

	TEST(@"-[objectAtIndex:]",