mirror of https://github.com/oxen-io/session-ios
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.
24 lines
538 B
Objective-C
24 lines
538 B
Objective-C
#import "NSSet+Functional.h"
|
|
|
|
@implementation NSSet (Functional)
|
|
|
|
- (BOOL)contains:(BOOL (^)(NSObject *))predicate {
|
|
for (NSObject *object in self) {
|
|
BOOL isPredicateSatisfied = predicate(object);
|
|
if (isPredicateSatisfied) { return YES; }
|
|
}
|
|
return NO;
|
|
}
|
|
|
|
- (NSSet *)filtered:(BOOL (^)(NSObject *))isIncluded {
|
|
NSMutableSet *result = [NSMutableSet new];
|
|
for (NSObject *object in self) {
|
|
if (isIncluded(object)) {
|
|
[result addObject:object];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
@end
|