From 515625c47fab947f82d7f8fc8daef885e56a7df6 Mon Sep 17 00:00:00 2001 From: Gil Date: Thu, 1 Feb 2018 07:55:49 -0800 Subject: Remove predecessorKey,Object,Document, etc (#735) This is dead code. I think it was probably useful in the RTDB because of the way it notified of changes, but we give changes with indexes in Firestore so I think we don't need it. --- .../Immutable/FSTArraySortedDictionary.m | 13 ---------- .../Immutable/FSTImmutableSortedDictionary.h | 8 ------ .../Immutable/FSTImmutableSortedDictionary.m | 4 --- .../third_party/Immutable/FSTImmutableSortedSet.h | 2 -- .../third_party/Immutable/FSTImmutableSortedSet.m | 4 --- .../Immutable/FSTTreeSortedDictionary.m | 30 ---------------------- .../Tests/FSTArraySortedDictionaryTests.m | 19 -------------- .../Immutable/Tests/FSTTreeSortedDictionaryTests.m | 19 -------------- 8 files changed, 99 deletions(-) (limited to 'Firestore/third_party') diff --git a/Firestore/third_party/Immutable/FSTArraySortedDictionary.m b/Firestore/third_party/Immutable/FSTArraySortedDictionary.m index ad1d68a..e9325a7 100644 --- a/Firestore/third_party/Immutable/FSTArraySortedDictionary.m +++ b/Firestore/third_party/Immutable/FSTArraySortedDictionary.m @@ -142,19 +142,6 @@ NS_ASSUME_NONNULL_BEGIN } } -- (nullable id)predecessorKey:(id)key { - NSInteger pos = [self findKey:key]; - if (pos == NSNotFound) { - [NSException raise:NSInternalInconsistencyException - format:@"Can't get predecessor key for non-existent key"]; - return nil; - } else if (pos == 0) { - return nil; - } else { - return self.keys[pos - 1]; - } -} - - (NSUInteger)indexOfKey:(id)key { return [self findKey:key]; } diff --git a/Firestore/third_party/Immutable/FSTImmutableSortedDictionary.h b/Firestore/third_party/Immutable/FSTImmutableSortedDictionary.h index a2264ec..cbb4da3 100644 --- a/Firestore/third_party/Immutable/FSTImmutableSortedDictionary.h +++ b/Firestore/third_party/Immutable/FSTImmutableSortedDictionary.h @@ -70,14 +70,6 @@ extern const int kSortedDictionaryArrayToRBTreeSizeThreshold; */ - (ValueType)objectForKeyedSubscript:(KeyType)key; -/** - * Gets the key before the given key in sorted order. - * - * @param key The key to look before. - * @return The key before the given one. - */ -- (nullable KeyType)predecessorKey:(KeyType)key; - /** * Returns the index of the key or NSNotFound if the key is not found. * diff --git a/Firestore/third_party/Immutable/FSTImmutableSortedDictionary.m b/Firestore/third_party/Immutable/FSTImmutableSortedDictionary.m index 6e78961..87c21a5 100644 --- a/Firestore/third_party/Immutable/FSTImmutableSortedDictionary.m +++ b/Firestore/third_party/Immutable/FSTImmutableSortedDictionary.m @@ -82,10 +82,6 @@ const int kSortedDictionaryArrayToRBTreeSizeThreshold = 25; return [self objectForKey:key]; } -- (nullable id)predecessorKey:(id)key { - @throw FSTAbstractMethodException(); // NOLINT -} - - (NSUInteger)indexOfKey:(id)key { @throw FSTAbstractMethodException(); // NOLINT } diff --git a/Firestore/third_party/Immutable/FSTImmutableSortedSet.h b/Firestore/third_party/Immutable/FSTImmutableSortedSet.h index d0f9906..b432f98 100644 --- a/Firestore/third_party/Immutable/FSTImmutableSortedSet.h +++ b/Firestore/third_party/Immutable/FSTImmutableSortedSet.h @@ -23,8 +23,6 @@ NS_ASSUME_NONNULL_BEGIN - (NSUInteger)count; - (BOOL)isEmpty; -- (KeyType)predecessorObject:(KeyType)entry; - /** * Returns the index of the object or NSNotFound if the object is not found. * diff --git a/Firestore/third_party/Immutable/FSTImmutableSortedSet.m b/Firestore/third_party/Immutable/FSTImmutableSortedSet.m index a23068e..1b63c2c 100644 --- a/Firestore/third_party/Immutable/FSTImmutableSortedSet.m +++ b/Firestore/third_party/Immutable/FSTImmutableSortedSet.m @@ -76,10 +76,6 @@ NS_ASSUME_NONNULL_BEGIN return [self.dictionary maxKey]; } -- (id)predecessorObject:(id)entry { - return [self.dictionary predecessorKey:entry]; -} - - (NSUInteger)indexOfObject:(id)object { return [self.dictionary indexOfKey:object]; } diff --git a/Firestore/third_party/Immutable/FSTTreeSortedDictionary.m b/Firestore/third_party/Immutable/FSTTreeSortedDictionary.m index b3e691f..ec0c483 100644 --- a/Firestore/third_party/Immutable/FSTTreeSortedDictionary.m +++ b/Firestore/third_party/Immutable/FSTTreeSortedDictionary.m @@ -87,36 +87,6 @@ NS_ASSUME_NONNULL_BEGIN return nil; } -- (nullable id)predecessorKey:(id)key { - NSComparisonResult cmp; - id node = self.root; - id rightParent = nil; - while (![node isEmpty]) { - cmp = self.comparator(key, node.key); - if (cmp == NSOrderedSame) { - if (![node.left isEmpty]) { - node = node.left; - while (![node.right isEmpty]) { - node = node.right; - } - return node.key; - } else if (rightParent != nil) { - return rightParent.key; - } else { - return nil; - } - } else if (cmp == NSOrderedAscending) { - node = node.left; - } else if (cmp == NSOrderedDescending) { - rightParent = node; - node = node.right; - } - } - @throw [NSException exceptionWithName:@"NonexistentKey" - reason:@"getPredecessorKey called with nonexistent key." - userInfo:@{@"key" : [key description]}]; -} - - (NSUInteger)indexOfKey:(id)key { NSUInteger prunedNodes = 0; id node = self.root; diff --git a/Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m b/Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m index 2099a26..bf17496 100644 --- a/Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m +++ b/Firestore/third_party/Immutable/Tests/FSTArraySortedDictionaryTests.m @@ -252,25 +252,6 @@ XCTAssertEqual((int)next, (int)toInsert.count, @"Check we traversed all of the items"); } -- (void)testPredecessorKey { - FSTArraySortedDictionary *map = - [[FSTArraySortedDictionary alloc] initWithComparator:[self defaultComparator]]; - map = [map dictionaryBySettingObject:@1 forKey:@1]; - map = [map dictionaryBySettingObject:@50 forKey:@50]; - map = [map dictionaryBySettingObject:@3 forKey:@3]; - map = [map dictionaryBySettingObject:@4 forKey:@4]; - map = [map dictionaryBySettingObject:@7 forKey:@7]; - map = [map dictionaryBySettingObject:@9 forKey:@9]; - - XCTAssertNil([map predecessorKey:@1], @"First object doesn't have a predecessor"); - XCTAssertEqualObjects([map predecessorKey:@3], @1, @"@1"); - XCTAssertEqualObjects([map predecessorKey:@4], @3, @"@3"); - XCTAssertEqualObjects([map predecessorKey:@7], @4, @"@4"); - XCTAssertEqualObjects([map predecessorKey:@9], @7, @"@7"); - XCTAssertEqualObjects([map predecessorKey:@50], @9, @"@9"); - XCTAssertThrows([map predecessorKey:@777], @"Expect exception about nonexistent key"); -} - // This is a macro instead of a method so that the failures show on the proper lines. #define ASSERT_ENUMERATOR(enumerator, start, end, step) \ do { \ diff --git a/Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m b/Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m index 344efba..3e06b30 100644 --- a/Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m +++ b/Firestore/third_party/Immutable/Tests/FSTTreeSortedDictionaryTests.m @@ -437,25 +437,6 @@ } } -- (void)testPredecessorKey { - FSTTreeSortedDictionary *map = - [[FSTTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]]; - map = [map dictionaryBySettingObject:@1 forKey:@1]; - map = [map dictionaryBySettingObject:@50 forKey:@50]; - map = [map dictionaryBySettingObject:@3 forKey:@3]; - map = [map dictionaryBySettingObject:@4 forKey:@4]; - map = [map dictionaryBySettingObject:@7 forKey:@7]; - map = [map dictionaryBySettingObject:@9 forKey:@9]; - - XCTAssertNil([map predecessorKey:@1], @"First object doesn't have a predecessor"); - XCTAssertEqualObjects([map predecessorKey:@3], @1, @"@1"); - XCTAssertEqualObjects([map predecessorKey:@4], @3, @"@3"); - XCTAssertEqualObjects([map predecessorKey:@7], @4, @"@4"); - XCTAssertEqualObjects([map predecessorKey:@9], @7, @"@7"); - XCTAssertEqualObjects([map predecessorKey:@50], @9, @"@9"); - XCTAssertThrows([map predecessorKey:@777], @"Expect exception about nonexistent key"); -} - // This is a macro instead of a method so that the failures show on the proper lines. #define ASSERT_ENUMERATOR(enumerator, start, end, step) \ do { \ -- cgit v1.2.3