Skip to content

Commit

Permalink
Remove MOGKeepIndexed
Browse files Browse the repository at this point in the history
While it can probably be useful it doesn't make sense to keep that
around while not having a MOGMapIndexed which would make more sense to
add given that MOGKeep (renamed to MOGMapDropNil) is just MOGMap
composed with MOGDropNil.
  • Loading branch information
hallski committed Mar 12, 2015
1 parent 797ae8d commit 440a14a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 43 deletions.
19 changes: 0 additions & 19 deletions MogKit/MogTransformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ typedef MOGReducer *(^MOGTransformation) (MOGReducer *);
*/
typedef id (^MOGMapBlock) (id val);

/**
* `MOGIndexedMapBlock` is the same as `MOGMapBlock`, only it also includes the index of the value in sequence
* that is being processed.
*/
typedef id (^MOGIndexedMapBlock) (NSUInteger index, id val);

/**
* `MOGPredicate` is a function that by examining the value returns YES or NO. It's typically used in `MOGFilter` or
* `MOGMapDropNil`.
Expand Down Expand Up @@ -177,19 +171,6 @@ MOGTransformation MOGReplaceWithDefault(NSDictionary *replacements, id defaultVa
*/
MOGTransformation MOGMapDropNil(MOGMapBlock mapBlock);

/**
* Creates a transformation that keeps values where `mapBlock` returns a non-nil value. This is similar to
* `MOGMapDropNil` with the difference that the index of the value is passed to `mapBlock` as well.
*
* @param mapBlock a function that determines if the transformation should pass on a value or not. non-nil to pass on,
* nil to drop it.
*
* @return a stateful transformation that drops all values where `mapBlock` returns nil.
*
* @see `MOGFilter`, `MOGRemove` and `MOGKeep`.
*/
MOGTransformation MOGKeepIndexed(MOGIndexedMapBlock mapBlock);

/**
* Creates a transformation that drops all duplicates. Whether it's a duplicate is determined by `isEqual:`
*
Expand Down
11 changes: 0 additions & 11 deletions MogKit/MogTransformation.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,6 @@ MOGTransformation MOGMapDropNil(MOGMapBlock mapBlock) {
return MOGCompose(MOGMap(mapBlock), MOGDropNil());
}

MOGTransformation MOGKeepIndexed(MOGIndexedMapBlock indexedMapBlock) {
return ^MOGReducer *(MOGReducer *reducer) {
__block NSUInteger index = 0;

return [MOGReducer stepReducerWithNextReducer:reducer reduceBlock:^(id acc, id val) {
id outValue = indexedMapBlock(index++, val);
return outValue != nil ? reducer.reduce(acc, outValue) : acc;
}];
};
}

MOGTransformation MOGUnique(void) {
return ^MOGReducer *(MOGReducer *reducer) {
NSMutableSet *seenValues = [NSMutableSet new];
Expand Down
12 changes: 0 additions & 12 deletions MogKitTests/MogTransformationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,6 @@ - (void)testKeepTransformation
XCTAssertEqualObjects(expected, result);
}

- (void)testKeepIndexedTransformation
{
NSArray *array = @[@1, @2, @3, @4, @5, @6, @7, @8, @9, @10];
NSArray *expected = @[@21, @23, @25, @27, @29];

NSArray *result = MOGTransform(array, MOGArrayReducer(), MOGKeepIndexed(^id(NSUInteger index, NSNumber *number) {
return index % 2 == 0 ? @(number.intValue + 20) : nil;
}));

XCTAssertEqualObjects(expected, result);
}

- (void)testUniqueTransformation
{
NSArray *array = @[@1, @2, @3, @4, @3, @2, @1, @8, @9, @10];
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ The transformation can then be reused and is not even tied to `RACStream`.
- Replace
- ReplaceWithDefault
- MapDropNil
- KeepIndexed
- Unique
- Dedupe
- Cat
Expand Down

0 comments on commit 440a14a

Please sign in to comment.