OmniSciDB  c07336695a
DictRef.h
Go to the documentation of this file.
1 #ifndef DICTREF_H
2 #define DICTREF_H
3 
4 #include <cstdint>
5 #include <cstdlib>
6 #include <functional>
7 
8 struct dict_ref_t {
9  int32_t dbId;
10  int32_t dictId;
11 
13  dict_ref_t(int32_t db_id, int32_t dict_id) : dbId(db_id), dictId(dict_id) {}
14 
15  inline bool operator==(const struct dict_ref_t& rhs) const {
16  return this->dictId == rhs.dictId && this->dbId == rhs.dbId;
17  }
18 
19  inline struct dict_ref_t& operator=(const struct dict_ref_t& rhs) {
20  this->dbId = rhs.dbId;
21  this->dictId = rhs.dictId;
22  return *this;
23  };
24 
25  inline bool operator<(const struct dict_ref_t& rhs) const {
26  return (this->dbId < rhs.dbId)
27  ? true
28  : (this->dbId == rhs.dbId) ? this->dictId < rhs.dictId : false;
29  }
30 
31  inline size_t operator()(const struct dict_ref_t& ref) const noexcept {
32  std::hash<int32_t> int32_hash;
33  return int32_hash(ref.dictId) ^ (int32_hash(ref.dbId) << 2);
34  }
35 };
36 
37 using DictRef = struct dict_ref_t;
38 
39 #endif
dict_ref_t()
Definition: DictRef.h:12
bool operator<(const struct dict_ref_t &rhs) const
Definition: DictRef.h:25
struct dict_ref_t & operator=(const struct dict_ref_t &rhs)
Definition: DictRef.h:19
int32_t dictId
Definition: DictRef.h:10
dict_ref_t(int32_t db_id, int32_t dict_id)
Definition: DictRef.h:13
bool operator==(const struct dict_ref_t &rhs) const
Definition: DictRef.h:15
int32_t dbId
Definition: DictRef.h:9
size_t operator()(const struct dict_ref_t &ref) const noexcept
Definition: DictRef.h:31