fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
835 B
29 lines
835 B
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
namespace folly {
|
|
namespace hash {
|
|
|
|
/*
|
|
* Thomas Wang 64 bit mix hash function
|
|
*/
|
|
|
|
inline uint64_t twang_mix64(uint64_t key) noexcept {
|
|
key = (~key) + (key << 21); // key *= (1 << 21) - 1; key -= 1;
|
|
key = key ^ (key >> 24);
|
|
key = key + (key << 3) + (key << 8); // key *= 1 + (1 << 3) + (1 << 8)
|
|
key = key ^ (key >> 14);
|
|
key = key + (key << 2) + (key << 4); // key *= 1 + (1 << 2) + (1 << 4)
|
|
key = key ^ (key >> 28);
|
|
key = key + (key << 31); // key *= 1 + (1 << 31)
|
|
return key;
|
|
}
|
|
|
|
} // namespace hash
|
|
} // namespace folly
|
|
|