diff options
author | Gil <mcg@google.com> | 2018-05-05 08:10:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-05 08:10:51 -0700 |
commit | a080e481b5e6fcbc2b645920051cf20fc8cad7a7 (patch) | |
tree | 5d5ce3d39be316ac82a2fd34c92b05fc9e67f83a /Firestore/core/src/firebase/firestore/immutable/sorted_set.h | |
parent | d158e420c6fa04997ee3d2a6c44fd53a52883d81 (diff) |
Port FSTDocumentKeySet to C++ DocumentKeySet (#1229)
* Define a Comparator for DocumentKey
* Automated migration from FSTDocumentKeySet to DocumentKeySet
* Manual fixups for DocumentKeySet
* Delete FSTDocumentKeySet
Diffstat (limited to 'Firestore/core/src/firebase/firestore/immutable/sorted_set.h')
-rw-r--r-- | Firestore/core/src/firebase/firestore/immutable/sorted_set.h | 16 |
1 files changed, 15 insertions, 1 deletions
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<value_type> 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: |