From a080e481b5e6fcbc2b645920051cf20fc8cad7a7 Mon Sep 17 00:00:00 2001 From: Gil Date: Sat, 5 May 2018 08:10:51 -0700 Subject: Port FSTDocumentKeySet to C++ DocumentKeySet (#1229) * Define a Comparator for DocumentKey * Automated migration from FSTDocumentKeySet to DocumentKeySet * Manual fixups for DocumentKeySet * Delete FSTDocumentKeySet --- .../core/src/firebase/firestore/immutable/sorted_set.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Firestore/core/src/firebase/firestore/immutable') diff --git a/Firestore/core/src/firebase/firestore/immutable/sorted_set.h b/Firestore/core/src/firebase/firestore/immutable/sorted_set.h index 6828106..d78fd61 100644 --- a/Firestore/core/src/firebase/firestore/immutable/sorted_set.h +++ b/Firestore/core/src/firebase/firestore/immutable/sorted_set.h @@ -61,6 +61,13 @@ class SortedSet { explicit SortedSet(M&& map) : map_{std::move(map)} { } + SortedSet(std::initializer_list entries, const C& comparator = {}) + : map_{comparator} { + for (auto&& value : entries) { + map_ = map_.insert(value, {}); + } + } + bool empty() const { return map_.empty(); } @@ -124,7 +131,14 @@ class SortedSet { } friend bool operator==(const SortedSet& lhs, const SortedSet& rhs) { - return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + if (lhs.size() != rhs.size()) { + return false; + } + return std::equal(lhs.begin(), lhs.end(), rhs.begin()); + } + + friend bool operator!=(const SortedSet& lhs, const SortedSet& rhs) { + return !(lhs == rhs); } private: -- cgit v1.2.3