EasySequence
EasySequence is a powerful fundamental library to process sequcence type, such as array, set, dictionary. All type object which conforms to NSFastEnumeration protocol can be initialzed to an EZSequence instance, then you can operation with them. Finally, you can transfer them back to the original type.
Requirements
iOS 8.0 or later.
Installation
EasySequence is available through CocoaPods. To install
it, simply add the following line to your Podfile:
To run the example project, clone the repo, and run pod install
from the Example directory first.
Features
Creating
- can be initialized from any object which conforms to
NSFastEnumeration
protocol.
Enumerating
- enumerate using
forEach:
- enumerate using
forEachWithIndex:
- enumerate using fast enumeration
- enumerate using NSEnumerator
Operations
- map
- flatten map
- filter
- select
- reject
- take
- skip
- any
- zip
- reduce
- group by
- first object
- first object where
- first index where
Transfer
- An object which conforms to
EZSTransfer
protocol can get an instance which transfer fromEZSequence
.
Thread-Safety Type
We provides thread-safety types as below:
- EZSArray
- EZSWeakArray
- EZSOrderedSet
- EZSWeakOrderedSet
- EZSQueue
Weak Container
EZSWeakArray
and EZSWeakOrderedSet
form weak reference to their's items.
Example
Create a sequence
A sequence, represented by the EZSequence
type, is a particular order in which ralated objects, or objects follow each other. For example, a NSArray
or a NSSet
is sequence ather than EZSequence
.
An EZSequence
can be initialized from any object which conforms to NSFastEnumeration
protocol.
Enumerating
- Enumerate using fast enumeration
- Enumerate using NSEnumerator
- Enumerate using block-based enumeration
Operations
- map
- select
- filter
- zip
For more examples and help, see also our unit test and API comments.
Transfer Protocol
An object which conforms to EZSTransfer
protocol can get an instance which transfer from EZSequence
.