diff options
Diffstat (limited to 'Firestore/core/src/firebase/firestore/immutable/sorted_map.h')
-rw-r--r-- | Firestore/core/src/firebase/firestore/immutable/sorted_map.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Firestore/core/src/firebase/firestore/immutable/sorted_map.h b/Firestore/core/src/firebase/firestore/immutable/sorted_map.h index 24eb5bf..6f4d91b 100644 --- a/Firestore/core/src/firebase/firestore/immutable/sorted_map.h +++ b/Firestore/core/src/firebase/firestore/immutable/sorted_map.h @@ -196,7 +196,12 @@ class SortedMap : public impl::SortedMapBase { case Tag::Array: return SortedMap{array_.erase(key)}; case Tag::Tree: - return SortedMap{tree_.erase(key)}; + tree_type result = tree_.erase(key); + if (result.empty()) { + // Flip back to the array representation for empty arrays. + return SortedMap{}; + } + return SortedMap{std::move(result)}; } FIREBASE_UNREACHABLE(); } @@ -244,6 +249,26 @@ class SortedMap : public impl::SortedMapBase { FIREBASE_UNREACHABLE(); } + const_iterator min() const { + switch (tag_) { + case Tag::Array: + return const_iterator(array_.min()); + case Tag::Tree: + return const_iterator{tree_.min()}; + } + FIREBASE_UNREACHABLE(); + } + + const_iterator max() const { + switch (tag_) { + case Tag::Array: + return const_iterator(array_.max()); + case Tag::Tree: + return const_iterator{tree_.max()}; + } + FIREBASE_UNREACHABLE(); + } + /** * Returns an iterator pointing to the first entry in the map. If there are * no entries in the map, begin() == end(). |