macoscope/MCSCollectionUtility

语言: Objective-C

git: https://github.com/macoscope/MCSCollectionUtility

README.md (中文)

MCSCollectionUtility

NSArray,NSSet和NSDictionary的类别提供了许多方法,使收集操作更容易和更清洁。

安装

要在您的应用程序中使用MCSCollectionUtility,只需将“Classes”文件夹拖到您的项目中,然后导入“MCSCollectionUtility.h”文件。

#import "MCSCollectionUtility.h"

Podfile

pod "MCSCollectionUtility", "~> 1.0.0"

例子

由于在创建的类别中有许多可用的方法,因此这些示例仅提供其中的一小部分。在创建文档时付出了更多努力,这些文档可以在示例下面找到(文档部分)。

检查数组中包含字母“a”的字符串的数量。

NSArray *elements = @[@"Warsaw", @"Berlin", @"London", @"New York", @"Paris"];

NSInteger count = [elements mcs_count:^BOOL(NSString *object) {
    return [object rangeOfString:@"a"].location != NSNotFound;
}];

//result 2

获取数组的元素,只要它们小于10.当第一个元素不满足此条件时停止。

NSArray *elements = @[@"1", @"5", @"7", @"10", @"16", @"8"];

NSArray *newElementsArray = [elements mcs_takeWhile:^BOOL(NSNumber *object) {
    return [object integerValue] < 10;
}];

//result @[@"1", @"5", @"7"]

创建只包含每个元素的一个表示的数组。

NSArray *elements = @[@"1", @"2", @"3", @"1", @"4"];

NSArray *newElementsArray = [elements mcs_unique];

//result @["1", @"2", @"3", @"4"];

文档

这些段落提供了MCSCollectionUtility中包含的类别中可用方法的文档。

NSArray的

- (NSArray *)mcs_skip:(NSInteger)number;

绕过指定接收数组的元素数量并返回包含其余元素的新数组。当number大于接收数组中的元素数时,它不会崩溃。

- (NSArray *)mcs_skipWhile:(BOOL(^)(id object))block;

只要通过评估指定块获得的值等于YES并且返回包含剩余元素的新数组,则在接收阵列中绕过元素。

- (NSArray *)mcs_take:(NSInteger)number;

从接收数组的开头返回一个包含指定数量的连续元素的新数组。

- (NSArray *)mcs_takeWhile:(BOOL(^)(id object))block;

返回一个新数组,其中包含接收数组开头的元素,对于这些元素,由指定块的求值返回的值等于YES。当对指定块的求值返回值等于NO时,停止将对象添加到结果数组。

- (NSArray *)mcs_where:(BOOL(^)(id object))block;

返回一个新数组,其中包含已接收数组的元素,其指定块返回值等于YES。

- (NSArray *)mcs_union:(NSArray *)array;

返回一个新数组,其中元素表示接收数组的并集,并使用compare:selector作为参数传递数组;

- (NSArray *)mcs_union:(NSArray *)array comparator:(BOOL(^)(id object1, id object2))block;

返回一个新数组,其中元素表示接收数组和使用指定块作为参数传递的数组,以比较两个对象。

- (NSArray *)mcs_unique;

返回具有接收数组的唯一元素的新数组。使用isEqual:selector确定元素的相等性。

- (NSArray *)mcs_unique:(BOOL(^)(id obj1, id obj2));

返回具有接收数组的唯一元素的新数组。使用指定的块确定元素的相等性。

- (NSArray *)mcs_select:(id(^)(id object))block;

返回一个新数组,其元素具有接收数组元素的投影。接收数组的每个元素使用指定的块投影到object或nil。

- (NSArray *)mcs_selectMany:(NSArray *(^)(id object))block;

返回一个新数组,其元素是接收数组元素的投影。接收数组的每个元素都使用指定的块投影到对象数组或nil中。将结果序列展平为由函数返回的序列。

- (NSArray *)mcs_map:(id(^)(id object))block;

返回一个新数组,其元素具有接收数组元素的投影。使用指定的块将接收数组的每个元素投影到一个对象中。

- (void)mcs_each:(void(^)(id object))block;

枚举接收数组的元素并为每个元素计算指定的块。

- (void)mcs_eachWithIndex:(void(^)(id object, NSUinteger index))block;

枚举接收数组的元素并为每个元素计算指定的块,提供有关当前求值对象的索引的附加信息。

- (NSInteger)mcs_count:(BOOL(^)(id object))block;

返回对指定块的求值返回值等于YES的接收数组的元素数。

- (NSInteger)mcs_minInteger:(NSInteger(^)(id object))block;

从作为使用指定块的接收数组的元素的转换结果接收的值返回最小NSInteger值。

- (CGFloat)mcs_minFloat:(CGFloat(^)(id object))block;

从接收到的值返回最小CGFloat值,作为使用指定块的接收数组元素转换的结果。

- (NSInteger)mcs_maxInteger:(NSInteger(^)(id object))block;

从作为使用指定块的接收数组的元素的转换结果接收的值返回最大NSInteger值。

- (CGFloat)mcs_maxFloat:(CGFloat(^)(id object))block;

从使用指定块的接收数组的元素转换结果接收的值返回最大CGFloat值。

- (NSInteger)mcs_sumInteger:(NSInteger(^)(id object))block;

返回使用指定块作为接收数组元素转换结果接收的NSInteger值的总和。

- (CGFloat)mcs_sumFloat:(CGFloat(^)(id object))block;

返回使用指定块作为接收数组元素转换结果接收的CGFloat值的总和。

- (NSInteger)mcs_averageInteger:(NSInteger(^)(id object))block;

返回使用指定块作为接收数组元素转换结果接收的平均NSInteger值。

- (CGFloat)mcs_averageFloat:(CGFloat(^)(id object))block;

返回使用指定块转换接收数组元素的结果所接收的平均CGFloat值。

- (id)mcs_first:(BOOL(^)(id object))block;

返回接收数组的第一个对象,对于该接收数组,对指定块的求值返回值等于YES。

- (id)mcs_last:(BOOL(^)(id object))block;

返回接收数组的最后一个对象,对于该接收数组,对指定块的求值返回值等于YES。

- (BOOL)mcs_single:(BOOL(^)(id object))block;

当对指定块的求值返回接收数组的一个元素的值等于YES时,返回YES。

- (BOOL)mcs_any:(BOOL(^)(id object))block;

当对指定块的求值为接收数组的至少一个元素返回等于YES的值时,返回YES。

- (BOOL)mcs_all:(BOOL(^)(id object))block;

当对指定块的求值返回接收数组的所有元素的值等于YES时,返回YES。

- (NSArray *)mcs_reverse;

以相反的顺序返回包含接收数组元素的新数组。

- (BOOL)mcs_hasAnyElement

当接收数组中至少有一个元素时返回YES,否则返回NO。

- (id)mcs_sample;

从接收数组中返回一个随机对象;

- (NSArray *)mcs_sample:(NSInteger)count;

返回一个包含接收数组的计数随机对象的新数组;

- (NSArray *)mcs_rotate:(NSInteger)count;

返回一个新数组,其中元素按count旋转。当count大于0时,元素的索引增加count,当count小于0时,元素的索引减少count。数组被视为圆阵列。

- (NSArray *)mcs_sort;

返回一个新数组,接收数组的元素使用compare:selector排序。

- (NSArray *)mcs_sortInDescendingOrder;

返回一个新数组,接收数组的元素使用compare:selector按降序排序。

的NSDictionary

- (void)mcs_each:(void(^)(id <NSCopying> key, id object))block;

枚举接收字典的元素,并为其中包含的每对键值评估指定的块。

- (NSDictionary *)mcs_where:(BOOL(^)(id <NSCopying> key, id object))block;

返回包含接收字典的键值对的新字典,其指定块返回值等于YES。

- (NSArray *)mcs_sortedKeys;

返回一个新数组,其中包含使用compare:selector排序的接收字典的键。

- (NSArray *)mcs_sortedKeysArray:(NSComparisonResult(^)(id <NSCopying> key1, id <NSCopying> key2))block;

返回一个新数组,其中包含使用指定块排序的接收字典的键。

- (NSArrat *)mcs_sortedValuesArray;

返回一个新数组,其中包含使用compare:selector排序的接收字典的值。

- (NSArray *)mcs_sortedValuesArray:(NSComparator)block;

返回一个新数组,其中包含使用指定块排序的接收字典的值;

- (NSInteger)mcs_count:(BOOL(^)(id <NSCopying> key, id object))block;

返回对指定块的求值返回值等于YES的接收字典的键值对的数量。

- (NSInteger)mcs_minInteger:(NSInteger(^)(id <NSCopying> key, id object))block;

从作为使用指定块的接收字典的键 - 值对的转换结果接收的值返回最小NSInteger值。

- (CGFloat)mcs_minFloat:(CGFloat(^)(id <NSCopying> key, id object))block;

从作为使用指定块的接收字典的键 - 值对的转换结果接收的值返回最小CGFloat值。

- (NSInteger)mcs_maxInteger:(NSInteger(^)(id <NSCopying> key, id object))block;

从作为使用指定块的接收字典的键 - 值对的转换结果接收的值返回最大NSInteger值。

- (CGFloat)mcs_maxFloat:(CGFloat(^)(id <NSCopying> key, id object))block;

从作为使用指定块的接收字典的键值转换结果接收的值返回最小CGFloat值。

- (NSInteger)mcs_sumInteger:(NSInteger(^)(id <NSCopying> key, id object))block;

返回作为使用指定块的接收字典的键值对转换结果而接收的NSInteger值的总和。

- (CGFloat)mcs_sumFloat:(CGFloat(^)(id <NSCopying> key, id object))block;

返回作为使用指定块的接收字典的键值对转换结果而接收的CGFloat值的总和。

- (NSInteger)mcs_averageInteger:(NSInteger(^)(id <NSCopying> key, id object))block;

返回作为使用指定块的接收字典的键值对转换结果而接收的平均NSInteger值。

- (CGFloat)mcs_averageFloat:(CGFloat(^)(id <NSCopying> key, id object))block;

返回作为使用指定块的接收字典的键 - 值对的转换结果而接收的平均CGFloat值。

- (BOOL)mcs_single:(BOOL(^)(id <NSCopying> key, id object))block;

当指定块的评估为接收字典的一个键值对返回等于YES的值时,返回YES。

- (BOOL)mcs_any:(BOOL(^)(id <NSCopying> key, id object))block;

当对指定块的评估为接收字典的至少一个键值对返回等于YES的值时,返回YES。

- (BOOL)mcs_all:(BOOL(^)(id <NSCopying> key, id object))block;

当对接收字典的所有键值对的指定块的评估返回值等于YES时,返回YES。

- (BOOL)mcs_hasAnyElement;

当接收字典中至少有一个键值对时返回YES,否则返回NO。

的NSSet

NSSet操作集几乎是NSArray可用操作的子集。由于NSSetdoes没有以任何指定顺序保留其元素,因此没有任何方法依赖于集合元素的顺序。

 - (void)mcs_each:(void(^)(id object))block;

枚举接收集的元素并为每个元素计算指定的块。

- (NSArray *)mcs_sort:(NSComparator)block;

返回一个新数组,其中包含使用指定块排序的接收集的元素。

- (NSSet *)mcs_where:(BOOL(^)(id object))block;

返回包含已接收数组元素的新集合,其指定块返回值等于YES。

 - (NSSet *)mcs_union:(NSSet *)set;

返回一个新集合,其中元素表示接收数组的集合,并使用compare:selector作为参数传递的集合;

 - (NSSet *)mcs_union:(NSSet *)set comparator:(BOOL(^)(id obj1, id obj2))block;

返回一个新集合,其中元素表示接收集合的并集,并使用指定块作为参数传递,以比较两个对象。

- (NSSet *)mcs_unique;

返回具有接收集的唯一元素的新集。使用isEqual:selector确定元素的相等性。

 - (NSSet *)mcs_unique:(BOOL(^)(id obj1, id obj2))block;

返回具有接收集的唯一元素的新集。使用指定的块确定元素的相等性。

 - (NSSet *)mcs_select:(id(^)(id object))block;

返回一个新元素,其元素具有接收集元素的投影。使用指定的块将接收集的每个元素投影到object或nil中。

 - (NSSet *)mcs_selectMany:(NSArray *(^)(id object))block;

返回一个新集合,其元素是接收集元素的投影。接收集的每个元素都使用指定的块投影到一组对象中或为零。将结果序列展平为由函数返回的序列。

- (NSSet *)mcs_map:(id(^)(id object))block;

返回一个新元素,其元素具有接收集元素的投影。使用指定的块将接收集的每个元素投影到一个对象中。

 - (NSInteger)mcs_count:(BOOL(^)(id object))block;

返回对指定块的求值返回值等于YES的接收集的元素数。

 - (NSInteger)mcs_minInteger:(NSInteger(^)(id object))block;

从作为使用指定块的接收集的元素的变换的结果接收的值返回最小NSinteger值。

- (CGFloat)mcs_minFloat:(CGFloat(^)(id object))block;

从作为使用指定块的接收集的元素的变换的结果接收的值返回最小CGFloat值。

 - (NSInteger)mcs_maxInteger:(NSInteger(^)(id object))block;

从作为使用指定块的接收集的元素的变换的结果接收的值返回最大NSInteter值。

 - (CGFloat)mcs_maxFloat:(CGFloat(^)(id object))block;

从作为使用指定块的接收集的元素的变换的结果接收的值返回最大CGFloat值。

 - (NSInteger)mcs_sumInteger:(NSInteger(^)(id object))block;

返回使用指定块作为接收数组元素转换结果接收的NSInteger值的总和。

- (CGFloat)mcs_sumFloat:(CGFloat(^)(id object))block;

返回使用指定块作为接收集元素转换结果接收的CGFloat值的总和。

- (NSInteger)mcs_averageInteger:(NSInteger(^)(id object))block;

返回作为使用指定块的接收集的元素的转换结果而接收的平均NSInteger值。

 - (CGFloat)mcs_averageFloat:(CGFloat(^)(id object))block;

返回使用指定块作为接收集元素转换结果接收的平均CGFloat值。

- (BOOL)mcs_single:(BOOL(^)(id object))block;

当对指定块的求值返回值等于接收集的一个元素的值时,返回YES。

- (BOOL)mcs_any:(BOOL(^)(id object))block;

当对指定块的评估为接收集的至少一个元素返回等于YES的值时,返回YES。

- (BOOL)mcs_all:(BOOL(^)(id object))block;

当对指定块的求值返回接收集的所有元素的值等于YES时,返回YES。

- (BOOL)mcs_hasAnyElement;

当接收集中至少有一个元素时返回YES,否则返回NO。

- (NSSet *)mcs_sample;

从接收集中返回一个随机对象。

联系

Macoscope

执照

版权所有2013 Macoscope,sp z o.o.

根据Apache许可证2.0版(“许可证”)获得许可;你可能不会用 此文件除了符合许可证外。您可以获得该副本 许可证

HTTP://呜呜呜.Apache.org/licenses/license-2.0

除非适用法律要求或书面同意,否则分发软件 根据许可证,按“原样”分发,不附带任何保证或 任何形式的条件,无论是明示的还是暗示的。请参阅许可证 管理许可下的权限和限制的特定语言。

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

MCSCollectionUtility

Categories for NSArray, NSSet and NSDictionary which provide many methods which make operations on collection easier and cleaner.

Installation

To use MCSCollectionUtility in your app just drag 'Classes' folder to yout project and import 'MCSCollectionUtility.h' file.

#import "MCSCollectionUtility.h"

Podfile

pod "MCSCollectionUtility", "~> 1.0.0"

Examples

As there are o lot of methods available in created categories these examples provide only small portion of it. More effort was put in creation of the documentation which is available below the examples (section Documentation).

Check how many elements of the array contains strings which contain letter 'a'.

NSArray *elements = @[@"Warsaw", @"Berlin", @"London", @"New York", @"Paris"];

NSInteger count = [elements mcs_count:^BOOL(NSString *object) {
    return [object rangeOfString:@"a"].location != NSNotFound;
}];

//result 2

Take the elements of the array as long as they are smaller than 10. Stop when first element doesn't fullfil this condition.

NSArray *elements = @[@"1", @"5", @"7", @"10", @"16", @"8"];

NSArray *newElementsArray = [elements mcs_takeWhile:^BOOL(NSNumber *object) {
    return [object integerValue] < 10;
}];

//result @[@"1", @"5", @"7"]

Create array with only one representation of the each element.

NSArray *elements = @[@"1", @"2", @"3", @"1", @"4"];

NSArray *newElementsArray = [elements mcs_unique];

//result @["1", @"2", @"3", @"4"];

Documentation

These paragraph provide documentation for methods available in categories contained in MCSCollectionUtility.

NSArray

- (NSArray *)mcs_skip:(NSInteger)number;

Bypasses specified number of elements of the receiving array and return a new array containing remaining elements. It does not crash when number is greater than number of elements in receiving array.

- (NSArray *)mcs_skipWhile:(BOOL(^)(id object))block;

Bypasses elements in the receiving array as long as value obtained by evaluation of the specified block is equal to YES and returns a new array containing remaining elements.

- (NSArray *)mcs_take:(NSInteger)number;

Returns a new array containing specified number of contiguous elements from the start of the receiving array.

- (NSArray *)mcs_takeWhile:(BOOL(^)(id object))block;

Returns a new array containing elements from the start of the receiving array for which value returned by evaluation of the specified block is equal to YES. Stops adding object to the result array when evaluation of the specified block returns value equal to NO.

- (NSArray *)mcs_where:(BOOL(^)(id object))block;

Returns a new array containing elements of the received array for which specified block returned value equal to YES.

- (NSArray *)mcs_union:(NSArray *)array;

Returns a new array with elements representing the union of the rececing array and array passed as argument using compare: selector;

- (NSArray *)mcs_union:(NSArray *)array comparator:(BOOL(^)(id object1, id object2))block;

Returns a new array with elements representing the union of the receiving array and array passed as argument using specified block to compare two objects.

- (NSArray *)mcs_unique;

Returns a new array with unique elements of the receiving array. Equality of the elements is determined using isEqual: selector.

- (NSArray *)mcs_unique:(BOOL(^)(id obj1, id obj2));

Returns a new array with unique elements of the receiving array. Equality of the elements is determined using specified block.

- (NSArray *)mcs_select:(id(^)(id object))block;

Returns a new array with elements with are projection of the elements of the receiving array. Each elements of the receiving array is projected into object or nil using specified block.

- (NSArray *)mcs_selectMany:(NSArray *(^)(id object))block;

Returns a new array with elements which are projection of the elements of the receiving array. Each element of the receiving array is projected into array of objects or nil using specified block. Flattens the resulting sequences into one which is returned by function.

- (NSArray *)mcs_map:(id(^)(id object))block;

Returns a new array with elements with are projection of the elements of the receiving array. Each element of the receiving array is projected into exactly one object using specified block.

- (void)mcs_each:(void(^)(id object))block;

Enumerates through elements of the receiving array and evaluates specified block for each of them.

- (void)mcs_eachWithIndex:(void(^)(id object, NSUinteger index))block;

Enumerates through elements of the receiving array and evaluates specified block for each of them providing additional information about the index of the currently evaluated object.

- (NSInteger)mcs_count:(BOOL(^)(id object))block;

Returns number of elements of the receiving array for which evaluation of the specified block returns value equal to YES.

- (NSInteger)mcs_minInteger:(NSInteger(^)(id object))block;

Returns a minimal NSInteger value from the values received as the result of transformations of the elements of the receiving array using specified block.

- (CGFloat)mcs_minFloat:(CGFloat(^)(id object))block;

Returns a minimal CGFloat value from the values received as the result of transformations of the elements of the receiving array using specified block.

- (NSInteger)mcs_maxInteger:(NSInteger(^)(id object))block;

Returns a maximal NSInteger value from the values received as the result of transformations of the elements of the receiving array using specified block.

- (CGFloat)mcs_maxFloat:(CGFloat(^)(id object))block;

Returns a maximal CGFloat value from the values received as the result of transformations of the elements of the receiving array using specified block.

- (NSInteger)mcs_sumInteger:(NSInteger(^)(id object))block;

Returns a sum of the NSInteger values received as the result of transformations of the elements of the receiving array using specified block.

- (CGFloat)mcs_sumFloat:(CGFloat(^)(id object))block;

Returns a sum of the CGFloat values received as the result of transformations of the elements of the receiving array using specified block.

- (NSInteger)mcs_averageInteger:(NSInteger(^)(id object))block;

Returns an average NSInteger value received as the result of transformations of the elements of the receiving array using specified block.

- (CGFloat)mcs_averageFloat:(CGFloat(^)(id object))block;

Returns an average CGFloat value received as the result of transformations of the elements of the receiving array using specified block.

- (id)mcs_first:(BOOL(^)(id object))block;

Returns the first object of the receiving array for which evaluation of the specified block returns value equal to YES.

- (id)mcs_last:(BOOL(^)(id object))block;

Returns the last object of the receiving array for which evaluation of the specified block returns value equal to YES.

- (BOOL)mcs_single:(BOOL(^)(id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for exactly one element of the receiving array.

- (BOOL)mcs_any:(BOOL(^)(id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for at least one element of the receiving array.

- (BOOL)mcs_all:(BOOL(^)(id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for all elements of the receiving array.

- (NSArray *)mcs_reverse;

Returns a new array containing elements of the receiving array in reversed order.

- (BOOL)mcs_hasAnyElement

Returns YES when there is at least one element in the receiving array, returns NO otherwise.

- (id)mcs_sample;

Returns one random object from the receiving array;

- (NSArray *)mcs_sample:(NSInteger)count;

Returns a new array containing count random objects of thje receiving array;

- (NSArray *)mcs_rotate:(NSInteger)count;

Returns a new array which elements rotated by count. When count is greater than 0 indexes of the elements are increased by count and when count is less than 0 indexes of elements are decreased by count. Array is treated as circle array.

- (NSArray *)mcs_sort;

Returns a new array which elements of the receiving array sorted using compare: selector.

- (NSArray *)mcs_sortInDescendingOrder;

Returns a new array which elements of the receiving array sorted in descending order using compare: selector.

NSDictionary

- (void)mcs_each:(void(^)(id <NSCopying> key, id object))block;

Enumerates through elements of the receiving dictionary and evaluates specified block for each pair key-value contained in it.

- (NSDictionary *)mcs_where:(BOOL(^)(id <NSCopying> key, id object))block;

Returns a new dictionary containing key-value pairs of the received dictionary for which specified block returned value equal to YES.

- (NSArray *)mcs_sortedKeys;

Returns a new array containing keys of the receiving dictionary ordered using compare: selector.

- (NSArray *)mcs_sortedKeysArray:(NSComparisonResult(^)(id <NSCopying> key1, id <NSCopying> key2))block;

Returns a new array containing keys of the receiving dictionary ordered using specified block.

- (NSArrat *)mcs_sortedValuesArray;

Returns a new array containing values of the receiving dictionary ordered using compare: selector.

- (NSArray *)mcs_sortedValuesArray:(NSComparator)block;

Returns a new array containing values of the receiving dictionary ordered using specified block;

- (NSInteger)mcs_count:(BOOL(^)(id <NSCopying> key, id object))block;

Returns number of key-value pairs of the receiving dictionary for which evaluation of the specified block returns value equal to YES.

- (NSInteger)mcs_minInteger:(NSInteger(^)(id <NSCopying> key, id object))block;

Returns a minimal NSInteger value from the values received as the result of transformations of the key-value pairs of the receiving dictionary using specified block.

- (CGFloat)mcs_minFloat:(CGFloat(^)(id <NSCopying> key, id object))block;

Returns a minimal CGFloat value from the values received as the result of transformations of the key-value pairs of the receiving dictionary using specified block.

- (NSInteger)mcs_maxInteger:(NSInteger(^)(id <NSCopying> key, id object))block;

Returns a maximal NSInteger value from the values received as the result of transformations of the key-value pairs of the receiving dictionary using specified block.

- (CGFloat)mcs_maxFloat:(CGFloat(^)(id <NSCopying> key, id object))block;

Returns a minimal CGFloat value from the values received as the result of transformations of the key-values of the receiving dictionary using specified block.

- (NSInteger)mcs_sumInteger:(NSInteger(^)(id <NSCopying> key, id object))block;

Returns a sum of the NSInteger values received as the result of transformations of the key-value pairs of the receiving dictionary using specified block.

- (CGFloat)mcs_sumFloat:(CGFloat(^)(id <NSCopying> key, id object))block;

Returns a sum of the CGFloat values received as the result of transformations of the key-value pairs of the receiving dictionary using specified block.

- (NSInteger)mcs_averageInteger:(NSInteger(^)(id <NSCopying> key, id object))block;

Returns an average NSInteger value received as the result of transformations of the key-value pairs of the receiving dictionary using specified block.

- (CGFloat)mcs_averageFloat:(CGFloat(^)(id <NSCopying> key, id object))block;

Returns an average CGFloat value received as the result of transformations of the key-value pairs of the receiving dictionary using specified block.

- (BOOL)mcs_single:(BOOL(^)(id <NSCopying> key, id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for exactly one key-value pair of the receiving dictionary.

- (BOOL)mcs_any:(BOOL(^)(id <NSCopying> key, id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for at least one key-value pair of the receiving dictionary.

- (BOOL)mcs_all:(BOOL(^)(id <NSCopying> key, id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for all key-value pairs of the receiving dictionary.

- (BOOL)mcs_hasAnyElement;

Returns YES when there is at least one key-value pair in the receiving dictionary, returns NO otherwise.

NSSet

NSSet operations set is pretty much a subset of the operations available for NSArray. Because of the fact NSSetdoesn't keeps his its elements in any specified order there are no methods which are dependent on the order of collection's elements.

 - (void)mcs_each:(void(^)(id object))block;

Enumerates through elements of the receiving set and evaluates specified block for each of them.

- (NSArray *)mcs_sort:(NSComparator)block;

Returns a new array containing elements of the receiving set ordered using specified block.

- (NSSet *)mcs_where:(BOOL(^)(id object))block;

Returns a new set containing elements of the received array for which specified block returned value equal to YES.

 - (NSSet *)mcs_union:(NSSet *)set;

Returns a new set with elements representing the union of the rececing array and set passed as argument using compare: selector;

 - (NSSet *)mcs_union:(NSSet *)set comparator:(BOOL(^)(id obj1, id obj2))block;

Returns a new set with elements representing the union of the receiving set and set passed as argument using specified block to compare two objects.

- (NSSet *)mcs_unique;

Returns a new set with unique elements of the receiving set. Equality of the elements is determined using isEqual: selector.

 - (NSSet *)mcs_unique:(BOOL(^)(id obj1, id obj2))block;

Returns a new set with unique elements of the receiving set. Equality of the elements is determined using specified block.

 - (NSSet *)mcs_select:(id(^)(id object))block;

Returns a new set with elements with are projection of the elements of the receiving set. Each elements of the receiving set is projected into object or nil using specified block.

 - (NSSet *)mcs_selectMany:(NSArray *(^)(id object))block;

Returns a new set with elements which are projection of the elements of the receiving set. Each element of the receiving set is projected into set of objects or nil using specified block. Flattens the resulting sequences into one which is returned by function.

- (NSSet *)mcs_map:(id(^)(id object))block;

Returns a new set with elements with are projection of the elements of the receiving set. Each element of the receiving set is projected into exactly one object using specified block.

 - (NSInteger)mcs_count:(BOOL(^)(id object))block;

Returns number of elements of the receiving set for which evaluation of the specified block returns value equal to YES.

 - (NSInteger)mcs_minInteger:(NSInteger(^)(id object))block;

Returns a minimal NSinteger value from the values received as the result of transformations of the elements of the receiving set using specified block.

- (CGFloat)mcs_minFloat:(CGFloat(^)(id object))block;

Returns a minimal CGFloat value from the values received as the result of transformations of the elements of the receiving set using specified block.

 - (NSInteger)mcs_maxInteger:(NSInteger(^)(id object))block;

Returns a maximal NSInteter value from the values received as the result of transformations of the elements of the receiving set using specified block.

 - (CGFloat)mcs_maxFloat:(CGFloat(^)(id object))block;

Returns a maximal CGFloat value from the values received as the result of transformations of the elements of the receiving set using specified block.

 - (NSInteger)mcs_sumInteger:(NSInteger(^)(id object))block;

Returns a sum of the NSInteger values received as the result of transformations of the elements of the receiving array using specified block.

- (CGFloat)mcs_sumFloat:(CGFloat(^)(id object))block;

Returns a sum of the CGFloat values received as the result of transformations of the elements of the receiving set using specified block.

- (NSInteger)mcs_averageInteger:(NSInteger(^)(id object))block;

Returns an average NSInteger value received as the result of transformations of the elements of the receiving set using specified block.

 - (CGFloat)mcs_averageFloat:(CGFloat(^)(id object))block;

Returns an average CGFloat value received as the result of transformations of the elements of the receiving set using specified block.

- (BOOL)mcs_single:(BOOL(^)(id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for exactly one element of the receiving set.

- (BOOL)mcs_any:(BOOL(^)(id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for at least one element of the receiving set.

- (BOOL)mcs_all:(BOOL(^)(id object))block;

Returns YES when evaluation of the specified block returns value equal to YES for all elements of the receiving set.

- (BOOL)mcs_hasAnyElement;

Returns YES when there is at least one element in the receiving set, returns NO otherwise.

- (NSSet *)mcs_sample;

Returns one random object from the receiving set.

Contact

Macoscope

License

Copyright 2013 Macoscope, sp z o.o.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.