You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/Signal/src/util/FunctionalUtil.h

33 lines
1.2 KiB
C

11 years ago
#import <Foundation/Foundation.h>
@interface NSArray (FunctionalUtil)
/// Returns true when any of the items in this array match the given predicate.
- (bool)any:(int (^)(id item))predicate;
11 years ago
/// Returns true when all of the items in this array match the given predicate.
- (bool)all:(int (^)(id item))predicate;
11 years ago
/// Returns the first item in this array that matches the given predicate, or else returns nil if none match it.
- (id)firstMatchingElseNil:(int (^)(id item))predicate;
11 years ago
/// Returns an array of all the results of passing items from this array through the given projection function.
- (NSArray *)map:(id (^)(id item))projection;
11 years ago
/// Returns an array of all the results of passing items from this array through the given projection function.
- (NSArray *)filter:(int (^)(id item))predicate;
11 years ago
/// Returns the sum of the doubles in this array of doubles.
- (double)sumDouble;
11 years ago
/// Returns the sum of the unsigned integers in this array of unsigned integers.
- (NSUInteger)sumNSUInteger;
11 years ago
/// Returns the sum of the integers in this array of integers.
- (NSInteger)sumNSInteger;
11 years ago
- (NSDictionary *)keyedBy:(id (^)(id))keySelector;
- (NSDictionary *)groupBy:(id (^)(id value))keySelector;
11 years ago
@end