Overview
Comment: | Add -[objectsFromIndex:toIndex:] to OFArray. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
14e949de94bf7f28e0979c9a3d9457c2 |
User & Date: | js on 2010-09-23 22:53:53 |
Other Links: | manifest | tags |
Context
2010-09-24
| ||
15:52 | objfw-config: Always print all flags in one line. check-in: 5fd57313ec user: js tags: trunk | |
2010-09-23
| ||
22:53 | Add -[objectsFromIndex:toIndex:] to OFArray. check-in: 14e949de94 user: js tags: trunk | |
16:40 | Some older gcc versions require an explicit cast here. check-in: 64a39262ca user: js tags: trunk | |
Changes
Modified src/OFArray.h from [2a76fef6e1] to [a63b2ee50b].
︙ | ︙ | |||
167 168 169 170 171 172 173 174 175 176 177 178 179 180 | * The returned object is <i>not</i> retained and autoreleased for performance * reasons! * * \return The last object of the array or nil */ - (id)lastObject; /** * Creates a string by joining all objects of the array. * * \param separator The string with which the objects should be joined * \return A string containing all objects joined by the separator */ - (OFString*)componentsJoinedByString: (OFString*)separator; | > > > > > > > > > > > > | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | * The returned object is <i>not</i> retained and autoreleased for performance * reasons! * * \return The last object of the array or nil */ - (id)lastObject; /** * Returns the objects from the specified index to the specified index as an * OFArray. * * \param start The index where the subarray starts * \param end The index where the subarray ends. * This points BEHIND the last object! * \return The subarray as a new autoreleased OFArray */ - (OFArray*)objectsFromIndex: (size_t)start toIndex: (size_t)end; /** * Creates a string by joining all objects of the array. * * \param separator The string with which the objects should be joined * \return A string containing all objects joined by the separator */ - (OFString*)componentsJoinedByString: (OFString*)separator; |
︙ | ︙ |
Modified src/OFArray.m from [ff4f2762a1] to [0afd3cde8f].
︙ | ︙ | |||
252 253 254 255 256 257 258 259 260 261 262 263 264 265 | - (id)lastObject { id *last = [array lastItem]; return (last != NULL ? *last : nil); } - (OFString*)componentsJoinedByString: (OFString*)separator { OFString *str; OFString **objs = [array cArray]; size_t i, count = [array count]; Class cls; | > > > > > > > > > > > > | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | - (id)lastObject { id *last = [array lastItem]; return (last != NULL ? *last : nil); } - (OFArray*)objectsFromIndex: (size_t)start toIndex: (size_t)end { size_t count = [array count]; if (end > count || start > end) @throw [OFOutOfRangeException newWithClass: isa]; return [OFArray arrayWithCArray: (id*)[array cArray] + start length: end - start]; } - (OFString*)componentsJoinedByString: (OFString*)separator { OFString *str; OFString **objs = [array cArray]; size_t i, count = [array count]; Class cls; |
︙ | ︙ |
Modified tests/OFArrayTests.m from [895b4e152f] to [c5886d17f7].
︙ | ︙ | |||
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | [[a[1] objectAtIndex: 2] isEqual: c_ary[2]]) TEST(@"-[indexOfObject:]", [a[0] indexOfObject: c_ary[1]] == 1) TEST(@"-[indexOfObjectIdenticalTo:]", [a[1] indexOfObjectIdenticalTo: c_ary[1]] == 1) TEST(@"-[replaceObject:withObject:]", R([m[0] replaceObject: c_ary[1] withObject: c_ary[0]]) && [[m[0] objectAtIndex: 0] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 1] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 2] isEqual: c_ary[2]]) | > > > > > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | [[a[1] objectAtIndex: 2] isEqual: c_ary[2]]) TEST(@"-[indexOfObject:]", [a[0] indexOfObject: c_ary[1]] == 1) TEST(@"-[indexOfObjectIdenticalTo:]", [a[1] indexOfObjectIdenticalTo: c_ary[1]] == 1) TEST(@"-[objectsFromIndex:toIndex", [[a[0] objectsFromIndex: 1 toIndex: 3] isEqual: ([OFArray arrayWithObjects: c_ary[1], c_ary[2], nil])]) TEST(@"-[replaceObject:withObject:]", R([m[0] replaceObject: c_ary[1] withObject: c_ary[0]]) && [[m[0] objectAtIndex: 0] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 1] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 2] isEqual: c_ary[2]]) |
︙ | ︙ |