-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOCLinq.h
More file actions
64 lines (49 loc) · 1.71 KB
/
OCLinq.h
File metadata and controls
64 lines (49 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
//
// OCLinq.h
// LINQForObjective-C
//
// Created by Yao Long on 7/18/16.
// Copyright © 2016 Yao Long. All rights reserved.
//
#import <Foundation/Foundation.h>
#define OCLQFrom(source) \
[OCLinq from:source]
typedef BOOL (^OCLQPredicate)(id item);
typedef id (^OCLQTransform)(id item);
typedef id (^OCLQKeySelector)(id item);
typedef id (^OCLQAggregateBlock)(id item, id aggregate);
@interface OCLinq : NSObject<NSFastEnumeration>
- (NSEnumerator *)objectEnumerator;
// source must be a instance of NSEnumerator, NSArray, NSDictionary or NSSet
+ (instancetype)from:(id)source;
- (instancetype)where:(OCLQPredicate)predicate;
- (instancetype)select:(OCLQTransform)transform;
- (instancetype)selectMany:(OCLQTransform)transform;
- (instancetype)orderBy:(OCLQKeySelector)keySelector;
- (instancetype)order;
- (instancetype)distinct;
- (instancetype)aggregate:(OCLQAggregateBlock)aggregate;
- (BOOL)any:(OCLQPredicate)predicate;
- (BOOL)all:(OCLQPredicate)predicate;
- (id)average;
- (id)max;
- (id)min;
- (id)sum;
- (instancetype)skip:(NSUInteger)count;
- (instancetype)skipWhile:(OCLQPredicate)predicate;
- (instancetype)take:(NSUInteger)count;
- (instancetype)takeWhile:(OCLQPredicate)predicate;
- (id)firstOrDefault:(id)defaultObj;
- (id)lastOrDefault:(id)defaultObj;
- (instancetype)reverse;
- (instancetype)contact:(OCLinq *)linq;
- (NSDictionary *)groupBy:(OCLQKeySelector)keySelector;
- (instancetype)join:(OCLinq *)linq keySelector1:(OCLQKeySelector)keySelctor1 keySelector2:(OCLQKeySelector)keySelctor2;
- (NSArray *)toArray;
- (NSDictionary *)toDictionary:(OCLQKeySelector)keySelector;
- (NSSet *)toSet;
@end
@interface OCLQPair : NSObject
@property (nonatomic) id first;
@property (nonatomic) id second;
@end