1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/common/reference_map.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/common.hpp"
12#include "duckdb/common/unordered_map.hpp"
13#include "duckdb/common/unordered_set.hpp"
14
15namespace duckdb {
16class Expression;
17
18template <class T>
19struct ReferenceHashFunction {
20 uint64_t operator()(const reference<T> &ref) const {
21 return std::hash<void *>()((void *)&ref.get());
22 }
23};
24
25template <class T>
26struct ReferenceEquality {
27 bool operator()(const reference<T> &a, const reference<T> &b) const {
28 return &a.get() == &b.get();
29 }
30};
31
32template <typename T, typename TGT>
33using reference_map_t = unordered_map<reference<T>, TGT, ReferenceHashFunction<T>, ReferenceEquality<T>>;
34
35template <typename T>
36using reference_set_t = unordered_set<reference<T>, ReferenceHashFunction<T>, ReferenceEquality<T>>;
37
38} // namespace duckdb
39