Overview
Comment: | Add a few array methods.
OFArray: OFMutableArray: |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
95e8e1e48614cc759ba2775af0fad639 |
User & Date: | js on 2012-06-10 16:03:01 |
Other Links: | manifest | tags |
Context
2012-06-10
| ||
16:07 | JSON: Make it possible to get the invalid line. check-in: 72c71c4eb2 user: js tags: trunk | |
16:03 | Add a few array methods. check-in: 95e8e1e486 user: js tags: trunk | |
13:28 | More API improvements. check-in: 11d3d69a22 user: js tags: trunk | |
Changes
Modified src/OFArray.h from [bde628b396] to [01516d5008].
︙ | ︙ | |||
268 269 270 271 272 273 274 275 276 277 278 279 280 281 | /** * \brief Returns a copy of the array with the order reversed. * * \return A copy of the array with the order reversed */ - (OFArray*)reversedArray; #ifdef OF_HAVE_BLOCKS /** * \brief Executes a block for each object. * * \param block The block to execute for each object */ - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block; | > > > > > > > > > > > > > > > > | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | /** * \brief Returns a copy of the array with the order reversed. * * \return A copy of the array with the order reversed */ - (OFArray*)reversedArray; /** * \brief Creates a new array with the specified object added. * * \param object The object to add * \return A new array with the specified object added */ - (OFArray*)arrayByAddingObject: (id)object; /** * \brief Creates a new array with the objects from the specified array added. * * \param array The array with objects to add * \return A new array with the objects from the specified array added */ - (OFArray*)arrayByAddingObjectsFromArray: (OFArray*)array; #ifdef OF_HAVE_BLOCKS /** * \brief Executes a block for each object. * * \param block The block to execute for each object */ - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block; |
︙ | ︙ |
Modified src/OFArray.m from [b302a054ee] to [7b45e24981].
︙ | ︙ | |||
599 600 601 602 603 604 605 606 607 608 609 610 611 612 | block(object, i++, &stop); if (stop) break; } } #endif #ifdef OF_HAVE_BLOCKS - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryWithSize: sizeof(id) | > > > > > > > > > > > > > > > > > > > > | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | block(object, i++, &stop); if (stop) break; } } #endif - (OFArray*)arrayByAddingObject: (id)object { OFMutableArray *ret = [[self mutableCopy] autorelease]; [ret addObject: object]; [ret makeImmutable]; return ret; } - (OFArray*)arrayByAddingObjectsFromArray: (OFArray*)array { OFMutableArray *ret = [[self mutableCopy] autorelease]; [ret addObjectsFromArray: array]; [ret makeImmutable]; return ret; } #ifdef OF_HAVE_BLOCKS - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryWithSize: sizeof(id) |
︙ | ︙ |
Modified src/OFMutableArray.h from [cef5851cfb] to [9c7f745e9f].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /** * \brief Adds an object to the end of the array. * * \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 inserted */ - (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 */ | > > > > > > > > > > > > > > > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /** * \brief Adds an object to the end of the array. * * \param object An object to add */ - (void)addObject: (id)object; /** * \brief Adds the objects from the specified OFArray to the end of the array. * * \brief array An array of objects to add */ - (void)addObjectsFromArray: (OFArray*)array; /** * \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 inserted */ - (void)insertObject: (id)object atIndex: (size_t)index; /** * \brief Inserts the objects from the specified OFArray at the specified index. * * \param array An array of objects * \param index The index where the objects should be inserted */ - (void)insertObjectsFromArray: (OFArray*)array 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 [2fdb683912] to [0bfaa52216].
︙ | ︙ | |||
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | } - (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 { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } | > > > > > > > > > > > > > > > > > > > > > > > > > | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | } - (void)addObject: (id)object { [self insertObject: object atIndex: [self count]]; } - (void)addObjectsFromArray: (OFArray*)array { [self insertObjectsFromArray: array atIndex: [self count]]; } - (void)insertObject: (id)object atIndex: (size_t)index { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - (void)insertObjectsFromArray: (OFArray*)array atIndex: (size_t)index { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFEnumerator *enumerator = [array objectEnumerator]; size_t i, count = [array count]; for (i = 0; i < count; i++) { id object = [enumerator nextObject]; assert(object != nil); [self insertObject: object atIndex: index + i]; } [pool release]; } - (void)replaceObjectAtIndex: (size_t)index withObject: (id)object { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } |
︙ | ︙ |
Modified src/OFMutableArray_adjacent.m from [fb3dbd6aee] to [e388818b36].
︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | - (void)insertObject: (id)object atIndex: (size_t)index { [array insertItem: &object atIndex: index]; [object retain]; mutations++; } - (void)replaceObject: (id)oldObject withObject: (id)newObject { id *objects = [array cArray]; | > > > > > > > > > > > > > > > > | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | - (void)insertObject: (id)object atIndex: (size_t)index { [array insertItem: &object atIndex: index]; [object retain]; mutations++; } - (void)insertObjectsFromArray: (OFArray*)array_ atIndex: (size_t)index { id *objects = [array_ objects]; size_t i, count = [array_ count]; [array insertItemsFromCArray: objects atIndex: index count: count]; for (i = 0; i < count; i++) [objects[i] retain]; mutations++; } - (void)replaceObject: (id)oldObject withObject: (id)newObject { id *objects = [array cArray]; |
︙ | ︙ |