Overview
Comment: | Rename -[reduceUsingBlock:] to -[foldUsingBlock:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d6faaf68b9471ffe06186dede227b86d |
User & Date: | js on 2011-07-22 17:09:56 |
Other Links: | manifest | tags |
Context
2011-07-22
| ||
17:17 | Add a test for -[foldUsingBlock:]. check-in: 32d6b7282a user: js tags: trunk | |
17:09 | Rename -[reduceUsingBlock:] to -[foldUsingBlock:]. check-in: d6faaf68b9 user: js tags: trunk | |
17:03 | Improve methods using blocks in OFDictionary. check-in: 6214a3be25 user: js tags: trunk | |
Changes
Modified src/OFArray.h from [825d39ec6d] to [ba9897850c].
︙ | ︙ | |||
25 26 27 28 29 30 31 | @class OFString; #ifdef OF_HAVE_BLOCKS typedef void (^of_array_enumeration_block_t)(id object, size_t index, BOOL *stop); typedef BOOL (^of_array_filter_block_t)(id odject, size_t index); typedef id (^of_array_map_block_t)(id object, size_t index); | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | @class OFString; #ifdef OF_HAVE_BLOCKS typedef void (^of_array_enumeration_block_t)(id object, size_t index, BOOL *stop); typedef BOOL (^of_array_filter_block_t)(id odject, size_t index); typedef id (^of_array_map_block_t)(id object, size_t index); typedef id (^of_array_fold_block_t)(id left, id right); #endif /** * \brief A class for storing objects in an array. */ @interface OFArray: OFObject <OFCopying, OFMutableCopying, OFCollection, OFSerialization> |
︙ | ︙ | |||
281 282 283 284 285 286 287 | * \param block A block which determines if the object should be in the new * array * \return A new, autoreleased OFArray */ - (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block; /** | | | | | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | * \param block A block which determines if the object should be in the new * array * \return A new, autoreleased OFArray */ - (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block; /** * \brief Folds the array to a single object using the specified block. * * If the array is empty, it will return nil. * * If there is only one object in the array, that object will be returned and * the block will not be invoked. * * If there are at least two objects, the block is invoked for each object * except the first, where left is always to what the array has already been * folded and right what should be added to left. * * \param block A block which folds two objects into one, which is called for * all objects except the first * \return The array folded to a single object */ - (id)foldUsingBlock: (of_array_fold_block_t)block; #endif @end @interface OFArrayEnumerator: OFEnumerator { OFArray *array; OFDataArray *dataArray; |
︙ | ︙ |
Modified src/OFArray.m from [720a88390f] to [ce913f08f5].
︙ | ︙ | |||
638 639 640 641 642 643 644 | } @finally { [self freeMemory: tmp]; } return ret; } | | | 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | } @finally { [self freeMemory: tmp]; } return ret; } - (id)foldUsingBlock: (of_array_fold_block_t)block { size_t count = [array count]; __block id current; if (count == 0) return nil; if (count == 1) |
︙ | ︙ |