From 06b763dfc4370cf6c95e75015c9a0f11187b0a22 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 1 Oct 2018 07:55:22 -0600 Subject: [PATCH] Remove unused methods/tests --- Signal/test/util/FunctionalUtilTest.m | 9 --------- SignalServiceKit/src/Util/FunctionalUtil.h | 4 ---- SignalServiceKit/src/Util/FunctionalUtil.m | 21 --------------------- 3 files changed, 34 deletions(-) diff --git a/Signal/test/util/FunctionalUtilTest.m b/Signal/test/util/FunctionalUtilTest.m index 9da0540fb..df286cbc5 100644 --- a/Signal/test/util/FunctionalUtilTest.m +++ b/Signal/test/util/FunctionalUtilTest.m @@ -38,15 +38,6 @@ test([[(@[@1,@2]) filter:^(NSNumber* x) { return x.intValue == 2; }] isEqualToArray:(@[@2])]); } --(void) testKeyedBy { - test([[@[] keyedBy:^id(id value) { return @true; }] isEqual:@{}]); - test([[@[@1] keyedBy:^id(id value) { return @true; }] isEqual:@{@true : @1}]); - testThrows(([(@[@1, @2]) keyedBy:^id(id value) { return @true; }])); - test([[(@[@1, @2]) keyedBy:^id(id value) { return value; }] isEqual:(@{@1 : @1, @2 : @2})]); - testThrows([(@[@1, @1, @2, @3, @5]) keyedBy:^id(NSNumber* value) { return @(value.intValue/2); }]); - test([[(@[@3, @5, @7, @11, @13]) keyedBy:^id(NSNumber* value) { return @(value.intValue/2); }] isEqual:(@{@1 : @3, @2 : @5, @3 : @7, @5 : @11, @6 : @13})]); -} - -(void) testGroupBy { test([[@[] groupBy:^id(id value) { return @true; }] isEqual:@{}]); test([[@[@1] groupBy:^id(id value) { return @true; }] isEqual:@{@true : @[@1]}]); diff --git a/SignalServiceKit/src/Util/FunctionalUtil.h b/SignalServiceKit/src/Util/FunctionalUtil.h index 021997a8f..4b4fd0c48 100644 --- a/SignalServiceKit/src/Util/FunctionalUtil.h +++ b/SignalServiceKit/src/Util/FunctionalUtil.h @@ -10,16 +10,12 @@ /// Returns true when all of the items in this array match the given predicate. - (bool)all:(int (^)(id item))predicate; -/// Returns the first item in this array that matches the given predicate, or else returns nil if none match it. -- (id)firstMatchingElseNil:(int (^)(id item))predicate; - /// Returns an array of all the results of passing items from this array through the given projection function. - (NSArray *)map:(id (^)(id item))projection; /// Returns an array of all the results of passing items from this array through the given projection function. - (NSArray *)filter:(int (^)(id item))predicate; -- (NSDictionary *)keyedBy:(id (^)(id))keySelector; - (NSDictionary *)groupBy:(id (^)(id value))keySelector; @end diff --git a/SignalServiceKit/src/Util/FunctionalUtil.m b/SignalServiceKit/src/Util/FunctionalUtil.m index a33279b79..8065d6cc5 100644 --- a/SignalServiceKit/src/Util/FunctionalUtil.m +++ b/SignalServiceKit/src/Util/FunctionalUtil.m @@ -46,15 +46,6 @@ } return true; } -- (id)firstMatchingElseNil:(int (^)(id item))predicate { - tskit_require(predicate != nil); - for (id e in self) { - if (predicate(e)) { - return e; - } - } - return nil; -} - (NSArray *)map:(id (^)(id item))projection { tskit_require(projection != nil); @@ -76,18 +67,6 @@ return r; } -- (NSDictionary *)keyedBy:(id (^)(id value))keySelector { - tskit_require(keySelector != nil); - - NSMutableDictionary *result = [NSMutableDictionary dictionary]; - - for (id value in self) { - result[keySelector(value)] = value; - } - tskit_require(result.count == self.count); - - return result; -} - (NSDictionary *)groupBy:(id (^)(id value))keySelector { tskit_require(keySelector != nil);