ObjFW  Check-in [4d523be264]

Overview
Comment:Add -[firstItem] to OFDataArray and -[firstObject] to OFArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4d523be264e515b4c3502f4c5cd4b74ecfbf6b97c1d4bc04fb2aabb5254e17cf
User & Date: js on 2009-11-26 09:50:12
Other Links: manifest | tags
Context
2009-11-28
20:29
Add -[indexOfObject:] and -[indexOfObjectIdenticalTo:] to OFArray. check-in: f1e3f965fc user: js tags: trunk
2009-11-26
09:50
Add -[firstItem] to OFDataArray and -[firstObject] to OFArray. check-in: 4d523be264 user: js tags: trunk
2009-11-22
16:57
Make it very clear that OFExceptions don't use autorelease pools. check-in: 0fbbfb7158 user: js tags: trunk
Changes

Modified src/OFArray.h from [44d57c9221] to [10a046cc18].

86
87
88
89
90
91
92
93

94
95
96
97
98
99
100





101

102
103
104
105
106
107
108
109
110
111
112
86
87
88
89
90
91
92

93
94
95
96
97
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
113
114
115
116
117







-
+







+
+
+
+
+
-
+












/**
 * \return The objects of the array as a C array
 */
- (id*)cArray;

/**
 * Returns a specific object of the OFDataArray.
 * Returns a specific object of the OFArray.
 *
 * \param index The number of the object to return
 * \return The specified object of the OFArray
 */
- (id)objectAtIndex: (size_t)index;

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

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

- addObject: (OFObject*)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 [f37fb0932b] to [4ee8184863].

167
168
169
170
171
172
173







174
175
176
177
178
179
180
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187







+
+
+
+
+
+
+







	return new;
}

- (id)objectAtIndex: (size_t)index
{
	return *((OFObject**)[array itemAtIndex: index]);
}

- (id)firstObject
{
	void *first = [array firstItem];

	return (first != NULL ? *((id*)first) : nil);
}

- (id)lastObject
{
	void *last = [array lastItem];

	return (last != NULL ? *((id*)last) : nil);
}

Modified src/OFDataArray.h from [302afd5292] to [f95fb1a241].

70
71
72
73
74
75
76





77

78
79
80
81
82
83
84
70
71
72
73
74
75
76
77
78
79
80
81

82
83
84
85
86
87
88
89







+
+
+
+
+
-
+







 *
 * \param index The number of the item to return
 * \return The specified item of the OFDataArray
 */
- (void*)itemAtIndex: (size_t)index;

/**
 * \return The first item of the OFDataArray or NULL
 */
- (void*)firstItem;

/**
 * \return The last item of the OFDataArray
 * \return The last item of the OFDataArray or NULL
 */
- (void*)lastItem;

/**
 * Adds an item to the OFDataArray.
 *
 * \param item A pointer to an arbitrary item

Modified src/OFDataArray.m from [019e3d878c] to [a0d0c15800].

75
76
77
78
79
80
81








82
83
84
85
86
87
88
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96







+
+
+
+
+
+
+
+







- (void*)itemAtIndex: (size_t)index
{
	if (index >= count)
		@throw [OFOutOfRangeException newWithClass: isa];

	return data + index * itemsize;
}

- (void*)firstItem
{
	if (data == NULL || count == 0)
		return NULL;

	return data;
}

- (void*)lastItem
{
	if (data == NULL || count == 0)
		return NULL;

	return data + (count - 1) * itemsize;