susumu.yata
null+****@clear*****
Mon Jan 5 16:50:48 JST 2015
susumu.yata 2015-01-05 16:50:48 +0900 (Mon, 05 Jan 2015) New Revision: eec78936a415cab6cb58de77cf892cf99034eb6f https://github.com/groonga/grnxx/commit/eec78936a415cab6cb58de77cf892cf99034eb6f Message: Add GeoPoint::hash(). (#132) Modified files: include/grnxx/data_types/scalar/geo_point.hpp Modified: include/grnxx/data_types/scalar/geo_point.hpp (+11 -0) =================================================================== --- include/grnxx/data_types/scalar/geo_point.hpp 2015-01-05 16:50:35 +0900 (157e078) +++ include/grnxx/data_types/scalar/geo_point.hpp 2015-01-05 16:50:48 +0900 (71d9ff3) @@ -98,6 +98,17 @@ class GeoPoint { return raw_latitude_ == raw_na_latitude(); } + uint64_t hash() const { + uint64_t x = static_cast<uint64_t>(raw_latitude_) | + (static_cast<uint64_t>(raw_longitude_) << 32); + x ^= x >> 33; + x *= uint64_t(0xFF51AFD7ED558CCDULL); + x ^= x >> 33; + x *= uint64_t(0xC4CEB9FE1A85EC53ULL); + x ^= x >> 33; + return x; + } + // TODO: std::memcmp() might be better. constexpr Bool operator==(const GeoPoint &rhs) const { return (is_na() || rhs.is_na()) ? Bool::na() : -------------- next part -------------- HTML����������������������������...ダウンロード