From aa3247ba48f78f4423874f2a64f00b12bf0b27d6 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Wed, 14 Jan 2015 13:43:32 -0500 Subject: Move BSON hashing functionality into BSONObj and BSONElement --- src/mongo/bson/bsonelement.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/mongo/bson/bsonelement.h') diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h index 67b345545ba..a5937349399 100644 --- a/src/mongo/bson/bsonelement.h +++ b/src/mongo/bson/bsonelement.h @@ -400,6 +400,15 @@ namespace mongo { */ int woCompare( const BSONElement &e, bool considerFieldName = true ) const; + /** + * Functor compatible with std::hash for std::unordered_{map,set} + * Warning: The hash function is subject to change. Do not use in cases where hashes need + * to be consistent across versions. + */ + struct Hasher { + size_t operator() (const BSONElement& elem) const; + }; + const char * rawdata() const { return data; } /** 0 == Equality, just not defined yet */ -- cgit v1.2.1