46 static_assert(std::is_copy_constructible_v<Value>);
51 template<
typename T>
size_t hash(
const T &value)
const
56 template<
typename T1,
typename T2>
bool equal(
const T1 &a,
const T2 &
b)
const
58 return IsEqual{}(a,
b);
62 using TBBMap = tbb::concurrent_hash_map<Key, Value, Hasher>;
78 return map_.find(accessor, key);
87 return map_.find(accessor, key);
96 return map_.insert(accessor, key);
101 return map_.insert(accessor, key);
108 bool remove(
const Key &key)
110 return map_.erase(key);
120 std::pair<Key, Value> item;
122 SetKey(Key key) : item(std::move(key),
Value()) {}
126 return Hash{}(this->item.first);
129 static uint64_t hash_as(
const Key &key)
134 friend bool operator==(
const SetKey &a,
const SetKey &
b)
136 return IsEqual{}(a.item.first,
b.item.first);
139 friend bool operator==(
const Key &a,
const SetKey &
b)
141 return IsEqual{}(a,
b.item.first);
144 friend bool operator==(
const SetKey &a,
const Key &
b)
146 return IsEqual{}(a.item.first,
b);
150 using UsedSet = Set<SetKey>;
153 std::unique_lock<Mutex> mutex;
154 std::pair<Key, Value> *data =
nullptr;
156 std::pair<Key, Value> *operator->()
171 accessor.mutex = std::unique_lock(mutex_);
172 SetKey *stored_key =
const_cast<SetKey *
>(set_.lookup_key_ptr_as(key));
176 accessor.data = &stored_key->item;
180 bool add(Accessor &accessor,
const Key &key)
182 accessor.mutex = std::unique_lock(mutex_);
183 const bool newly_added = !set_.contains_as(key);
184 SetKey &stored_key =
const_cast<SetKey &
>(set_.lookup_key_or_add_as(key));
185 accessor.data = &stored_key.item;
191 std::unique_lock
lock(mutex_);
192 return set_.remove_as(key);
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET