• Stars
    star
    208
  • Rank 189,015 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NSEnumerator LINQ category

#NSEnumeratorLinq

Just imagine the power of LINQ on iOS and OS X platforms.

##Stop talking, show me the codeโ€ฆ

Example with filtering, transforming and another filtering array:

NSArray * arr = @[@1,@2,@3,@4,@5,@6,@7,@8];
NSArray * subarr = [[[[[arr objectEnumerator]                                // 1,2,3,4,5,6,7,8
                    where:^(id a){return [a intValue]%2 == 1}]               // 1,3,5,7
                    select:^(id a){return @([a intValue]*2)}]                // 2,6,10,14
                    where:^(id a){return [a intValue]>2 && [a intValue]<12}] // 6,10
                    allObjects];

##Main Objective

Main objective is to implement all of these methods: http://msdn.microsoft.com/en-us/library/system.linq.enumerable_methods.aspx

##Implemented Features

###Main Methods

+ (NSEnumerator *)enumeratorWithBlock:(id (^)())func;
- (NSEnumerator *)where:(BOOL (^)(id object))predicate;
- (NSEnumerator *)where_i:(BOOL (^)(id object,int index))predicate;
- (NSEnumerator *)select:(id (^)(id object))predicate;
- (NSEnumerator *)select_i:(id (^)(id object,int index))predicate;
- (NSEnumerator *)select_parallel:(id (^)(id object))func;
- (NSEnumerator *)select_parallel:(id (^)(id object))func
                         priority:(long)priority;
- (NSEnumerator *)distinct;
- (NSEnumerator *)distinct:(id<NSCopying> (^)(id object))func;
- (NSEnumerator *)ofType:(Class) type;

- (NSEnumerator *)skip:(NSInteger)count;
- (NSEnumerator *)skipWhile:(BOOL (^)(id object))predicate;
- (NSEnumerator *)take:(NSInteger)count;
- (NSEnumerator *)takeWhile:(BOOL (^)(id object))predicate;

- (NSEnumerator *)groupBy:(id<NSCopying> (^)(id object))keySelector;
- (NSEnumerator *)splitBy:(id<NSCopying> (^)(id object))keySelector;
- (NSEnumerator *)selectMany:(NSEnumerator * (^)(id object))func;

- (NSEnumerator *)orderBy:(id (^)(id object))func
               comparator:(NSComparisonResult(^)(id obj1, id obj2))objectComparator;
- (NSEnumerator *)orderByDescending:(id (^)(id object))func
                         comparator:(NSComparisonResult(^)(id obj1, id obj2))objectComparator;
- (NSEnumerator *)orderBy:(id (^)(id object))func;
- (NSEnumerator *)orderByDescending:(id (^)(id object))func;

###Aggregators

- (id)aggregate:(id (^)(id accumulator,id object))func initValue:(id)value;
- (BOOL)all;
- (BOOL)all:(BOOL (^)(id object))predicate;
- (BOOL)any;
- (BOOL)any:(BOOL (^)(id object))predicate;
- (BOOL)none;
- (BOOL)none:(BOOL (^)(id object))predicate;
- (BOOL)contains:(id)object;
- (BOOL)containsObject:(id)object;
- (NSInteger)count;
- (NSInteger)count:(BOOL (^)(id object))predicate;
- (id)elect:(id (^)(id obj1,id obj2))func;
- (id)max;
- (id)max:(id (^)(id object))func;
- (id)min;
- (id)min:(id (^)(id object))func;
- (double)sum;
- (double)average;
- (BOOL)sequenceEqual:(NSEnumerator *)other;
- (BOOL)sequenceEqual:(NSEnumerator *) other
       withComparator:(BOOL(^)(id obj1, id obj2))equalityComparator;

###Single Object Returners

- (id)elementAt:(NSInteger)index;
- (id)firstOrDefault;
- (id)firstOrDefault:(BOOL (^)(id))predicate;
- (id)lastOrDefault;
- (id)lastOrDefault:(BOOL (^)(id))predicate;

###Set Methods

- (NSEnumerator *)concat:(NSEnumerator *)secondEnumerator;
- (NSEnumerator *)concatOne:(id)one;
- (NSEnumerator *)union:(NSEnumerator *)secondEnumerator;
- (NSEnumerator *)intersect:(NSEnumerator *)secondEnumerator;
- (NSEnumerator *)except:(NSEnumerator *)secondEnumerator;

- (NSEnumerator *)zip:(NSEnumerator *)secondEnumerator
                 with:(id (^)(id obj1,id obj2))func;

- (NSEnumerator *)join:(NSEnumerator *)secondEnumerator
         firstSelector:(id<NSCopying> (^)(id object))firstSelector
        secondSelector:(id<NSCopying> (^)(id object))secondSelector;

- (NSEnumerator *)join:(NSEnumerator *)secondEnumerator
         firstSelector:(id<NSCopying> (^)(id object))firstSelector
        secondSelector:(id<NSCopying> (^)(id object))secondSelector
        resultSelector:(id (^)(id,id))resultSelector;

- (NSEnumerator *)groupJoin:(NSEnumerator *)secondEnumerator
              firstSelector:(id<NSCopying> (^)(id object))firstSelector
             secondSelector:(id<NSCopying> (^)(id object))secondSelector;

###Export methods

- (NSArray *)toArray;
- (NSSet *)toSet;
- (NSDictionary *)toDictionary;
- (NSDictionary *)toDictionary:(id<NSCopying> (^)(id object))keySelector;
- (NSDictionary *)toLookup;
- (NSDictionary *)toLookup:(id<NSCopying> (^)(id object))keySelector;

###Generation Methods

+ (NSEnumerator *)range:(int)start count:(int)count;
+ (NSEnumerator *)repeat:(id)item count:(int)count;
+ (NSEnumerator *)empty;

###I/O Methods

+ (NSEnumerator *)readBytes:(NSString *)path;
+ (NSEnumerator *)readLines:(NSString *)path;

###NSString Category Methods

+ (id)stringByJoin:(NSEnumerator *)unichars
     withSeparator:(NSString *)separator;
- (NSEnumerator *)enumerateCharacters;
- (NSEnumerator *)enumerateComponentsSeparatedByString:(NSString *)separator
                                               options:(NSStringCompareOptions)options;
- (NSEnumerator *)enumerateComponentsSeparatedByString:(NSString *)separator;

Written with Mou - The missing Markdown editor for web developers

More Repositories

1

ABCalendarPicker

Fully configurable iOS calendar UI component with multiple layouts and smooth animations.
Objective-C
712
star
2

boolinq

Simplest C++ header-only LINQ template library
C++
583
star
3

LaunchScreenViewController

iOS View Controller for loading default launch screen in app and maybe to add some animations to it
Objective-C
186
star
4

Unipool

Solidity
73
star
5

UIView-FastScreenshot

The fastest way to get iOS screenshot
C
53
star
6

UIImage-DecompressAndMap

iOS library for quickly displaying images while scrolling
Objective-C
52
star
7

MissingAnchors

Backport of Apple NSLayoutAnchor API to iOS7 and some missings like `sizeAnchor` and `edgesAnchor`
Objective-C
37
star
8

Cliple

Simple clipboard manage app for Mac OS X
C
32
star
9

iBackupMounter

Just mount iOS iTunes backups to OS X file system
Objective-C
30
star
10

DeluxeInjection

Simplest Objective-C Dependency Injection (DI๐Ÿ’‰) implementation ever
Objective-C
29
star
11

parity-trace-decoder

Parity Trace Decoder
JavaScript
26
star
12

Mattericon

Native OS X client to drag-n-drop Material Icons to Sketch
Objective-C
26
star
13

GasTray

Simple gas tray app for macOS
Objective-C
20
star
14

ABIntentions

Collection of iOS intentions. Inspired by http://bendyworks.com/geekville/articles/2014/2/single-responsibility-principle-ios and http://chris.eidhof.nl/posts/intentions.html
Objective-C
14
star
15

NSData-AsyncCacher

NSData category for async loading data from url and calling block. Requested data is cached with NSCache and can be requested multiple times simultaneously.
Objective-C
12
star
16

ABStaticTableViewController

Dynamically hide rows and sections in static UITableView inside UITableViewController.
Objective-C
11
star
17

ShardedToken

JavaScript
11
star
18

CroptateView

Simple view allowing to crop and rotate photos
Objective-C
10
star
19

RTLButton

UIButton subclass with image and title aligned Right To Left
Ruby
10
star
20

zolidity

Simplest Solidity compiler
TypeScript
9
star
21

Soliditemp

TruffleFramework template with travis-ci.org and coveralls.io configured
Solidity
9
star
22

CALayer-AutoresizingMask

Add UIViewAutoresize support to iOS CALayers and fast UIView to CALayer conversion method
Objective-C
8
star
23

ERC2608

Token Standard with Safe Arbitrary Call
Solidity
8
star
24

PieDisk

Cross-platform pie-chart disk space analyzer
C++
8
star
25

LeaderboardKit

iOS and OSX social leaderboards and highscore push notifications on top of Apple CloudKit
Objective-C
5
star
26

AirPlayMe

I am trying to stream any video file to my Apple TV step by step
5
star
27

UIView-IBDesignable

IB_DESIGNABLE category to UIView
Objective-C
5
star
28

ABCollectionViewFRC

NSFetchedResultsControllerDelegate wrapper for UICollectionView animated changes
Ruby
5
star
29

MultiToken

ERC20 token solidity smart contract allowing aggreagate ERC20 tokens
JavaScript
5
star
30

k29

256-byte assembly gradient spiral with controls
Assembly
3
star
31

UINavigationController-StatusBar

UINavigationController with overloaded methods to provide child status bar state
Objective-C
3
star
32

MusicFinder

Find artists by name, browse albums and songs with MusicBrainz.org web service.
Objective-C
3
star
33

Xross

All-directions-enabled UIPageViewController
Objective-C
2
star
34

Blockhashes

Solidity
2
star
35

TypoToken

JavaScript
2
star
36

k06a

2
star
37

DailyPhoto

Demo RSS image viewer for http://fotki.yandex.ru/calendar/rss2
Objective-C
1
star
38

reghope

Automatically exported from code.google.com/p/reghope
C++
1
star
39

truffle-string-multi-literal

JavaScript
1
star
40

Uzh

Simple snake game for iOS
Objective-C
1
star
41

IntInt

Extra efficient ะก++ BigInt implementation
C++
1
star
42

stliw

Automatically exported from code.google.com/p/stliw
C++
1
star
43

ML-2016

HTML
1
star
44

RitM

RitM in the Middle โ€“ My diploma project for network traffic retransmission
C++
1
star
45

NSNull-SelfOrNil

Simple category for NSNull to return nil on self method call
Ruby
1
star
46

ABStackedRollView

Simple UICollectionView son, which looks like two piles exchanging their sheets.
Objective-C
1
star