diff options
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model/document_key.h')
-rw-r--r-- | Firestore/core/src/firebase/firestore/model/document_key.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Firestore/core/src/firebase/firestore/model/document_key.h b/Firestore/core/src/firebase/firestore/model/document_key.h index 4bdc04b..3f5f342 100644 --- a/Firestore/core/src/firebase/firestore/model/document_key.h +++ b/Firestore/core/src/firebase/firestore/model/document_key.h @@ -17,6 +17,7 @@ #ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_MODEL_DOCUMENT_KEY_H_ #define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_MODEL_DOCUMENT_KEY_H_ +#include <functional> #include <initializer_list> #include <memory> #include <string> @@ -26,6 +27,8 @@ #endif // defined(__OBJC__) #include "Firestore/core/src/firebase/firestore/model/resource_path.h" +#include "Firestore/core/src/firebase/firestore/util/comparison.h" +#include "Firestore/core/src/firebase/firestore/util/hashing.h" #include "absl/strings/string_view.h" namespace firebase { @@ -56,15 +59,15 @@ class DocumentKey { return [FSTDocumentKey keyWithPath:path()]; } - std::string ToString() const { - return path().CanonicalString(); - } - NSUInteger Hash() const { - return std::hash<std::string>{}(ToString()); + return util::Hash(ToString()); } #endif + std::string ToString() const { + return path().CanonicalString(); + } + /** * Creates and returns a new document key using '/' to split the string into * segments. @@ -116,7 +119,20 @@ inline bool operator>=(const DocumentKey& lhs, const DocumentKey& rhs) { return lhs.path() >= rhs.path(); } +struct DocumentKeyHash { + size_t operator()(const DocumentKey& key) const { + return util::Hash(key.path()); + } +}; + } // namespace model + +namespace util { + +template <> +struct Comparator<model::DocumentKey> : public std::less<model::DocumentKey> {}; + +} // namespace util } // namespace firestore } // namespace firebase |