6 #ifndef TURI_VALUE_CONTAINER_MAPPER_INTERNAL_H_ 7 #define TURI_VALUE_CONTAINER_MAPPER_INTERNAL_H_ 14 #include <core/util/code_optimization.hpp> 15 #include <core/util/cityhash_tc.hpp> 17 namespace turi {
namespace vc_internal {
35 template <
typename T,
class IsMatch =
void>
38 static constexpr
bool holds_value()
GL_HOT_INLINE {
return false; }
39 static constexpr
bool use_explicit_delete()
GL_HOT_INLINE {
return false; }
40 static constexpr
bool key_is_exact()
GL_HOT_INLINE {
return false; }
45 const T& value()
const {
DASSERT_TRUE(
false);
return T(); }
47 bool operator==(
const vc_hashkey& other)
const {
48 return _key == other._key;
51 bool operator!=(
const vc_hashkey& other)
const {
52 return !(_key == other._key);
55 size_t hash()
const {
return _key; }
57 static constexpr
bool is_empty(
const vc_hashkey& key) {
61 static constexpr
bool is_deleted(
const vc_hashkey& key) {
62 return use_explicit_delete() && !(key._key == ~(uint64_t(0)^uint64_t(0x1)));
67 k._key = ~uint64_t(0);
73 k._key = ~(uint64_t(0)^uint64_t(0x1));
84 class vc_hashkey<T, typename
std::enable_if<std::is_integral<T>::value>::type> {
86 static constexpr
bool holds_value()
GL_HOT_INLINE {
return true; }
87 static constexpr
bool use_explicit_delete()
GL_HOT_INLINE {
return false; }
88 static constexpr
bool key_is_exact()
GL_HOT_INLINE {
return true; }
93 const T& value()
const {
return _value; }
95 bool operator==(
const vc_hashkey& other)
const {
96 return _value == other._value;
99 bool operator!=(
const vc_hashkey& other)
const {
100 return _value != other._value;
103 size_t hash()
const {
return _value; }
106 return key._value == ~(T(0));
110 return use_explicit_delete() && (key._value == (~(T(0)) ^ 1));
122 k._value = ~(T(0)) ^ 1;
134 template <
typename T,
class IsMatch =
void>
138 typedef T value_type;
145 const key_type& key()
const {
return _key; }
146 const T& value()
const {
return _value; }
159 template <
typename T>
161 T, typename
std::enable_if<vc_hashkey<T>::holds_value()>::type> {
165 typedef T value_type;
172 const key_type& key()
const {
return _key_and_value; }
173 const T& value()
const {
return _key_and_value.value(); }
static uint64_t hash64(const char *s, size_t len)
#define GL_HOT_INLINE_FLATTEN
#define DASSERT_TRUE(cond)