Initial Work for Range Controller to Support Supplementary Elements (#3140)

* Initial work supporting supplementaries in range controller

* Rename indexPathForElementIfItem
This commit is contained in:
Adlai Holler
2017-03-06 10:11:00 -08:00
committed by GitHub
parent d0ad24808b
commit d59ea3902d
12 changed files with 172 additions and 69 deletions

View File

@@ -217,3 +217,31 @@
id __val = x;\
((c *) ([__val isKindOfClass:[c class]] ? __val : nil));\
})
/**
* Create a new set by mapping `collection` over `work`, ignoring nil.
*/
#define ASSetByFlatMapping(collection, decl, work) ({ \
NSMutableSet *s = [NSMutableSet set]; \
for (decl in collection) {\
id result = work; \
if (result != nil) { \
[s addObject:result]; \
} \
} \
s; \
})
/**
* Create a new array by mapping `collection` over `work`, ignoring nil.
*/
#define ASArrayByFlatMapping(collection, decl, work) ({ \
NSMutableArray *a = [NSMutableArray array]; \
for (decl in collection) {\
id result = work; \
if (result != nil) { \
[a addObject:result]; \
} \
} \
a; \
})