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.
		
		
		
		
		
			
		
			
	
	
		
			33 lines
		
	
	
		
			748 B
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			33 lines
		
	
	
		
			748 B
		
	
	
	
		
			Matlab
		
	
| 
											5 years ago
										 | #import "NSSet+Functional.h" | ||
|  | 
 | ||
|  | @implementation NSSet (Functional) | ||
|  | 
 | ||
|  | - (BOOL)contains:(BOOL (^)(id))predicate { | ||
|  |     for (id object in self) { | ||
|  |         BOOL isPredicateSatisfied = predicate(object); | ||
|  |         if (isPredicateSatisfied) { return YES; } | ||
|  |     } | ||
|  |     return NO; | ||
|  | } | ||
|  | 
 | ||
|  | - (NSSet *)filtered:(BOOL (^)(id))isIncluded { | ||
|  |     NSMutableSet *result = [NSMutableSet new]; | ||
|  |     for (id object in self) { | ||
|  |         if (isIncluded(object)) { | ||
|  |             [result addObject:object]; | ||
|  |         } | ||
|  |     } | ||
|  |     return result; | ||
|  | } | ||
|  | 
 | ||
|  | - (NSSet *)map:(id (^)(id))transform { | ||
|  |     NSMutableSet *result = [NSMutableSet new]; | ||
|  |     for (id object in self) { | ||
|  |         id transformedObject = transform(object); | ||
|  |         [result addObject:transformedObject]; | ||
|  |     } | ||
|  |     return result; | ||
|  | } | ||
|  | 
 | ||
|  | @end |