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 | |
15 | namespace duckdb { |
16 | class Expression; |
17 | |
18 | template <class T> |
19 | struct ReferenceHashFunction { |
20 | uint64_t operator()(const reference<T> &ref) const { |
21 | return std::hash<void *>()((void *)&ref.get()); |
22 | } |
23 | }; |
24 | |
25 | template <class T> |
26 | struct ReferenceEquality { |
27 | bool operator()(const reference<T> &a, const reference<T> &b) const { |
28 | return &a.get() == &b.get(); |
29 | } |
30 | }; |
31 | |
32 | template <typename T, typename TGT> |
33 | using reference_map_t = unordered_map<reference<T>, TGT, ReferenceHashFunction<T>, ReferenceEquality<T>>; |
34 | |
35 | template <typename T> |
36 | using reference_set_t = unordered_set<reference<T>, ReferenceHashFunction<T>, ReferenceEquality<T>>; |
37 | |
38 | } // namespace duckdb |
39 |