| 72 | }; |
| 73 | |
| 74 | class Duplet : public Multiplet<int, 2> { |
| 75 | public: |
| 76 | using Parent = Multiplet<int, 2>; |
| 77 | Duplet(int v1=0, int v2=0) { |
| 78 | Parent::m_ori_data << v1, v2; |
| 79 | if (v1 >= v2) { |
| 80 | Parent::m_data << v1, v2; |
| 81 | } else { |
| 82 | Parent::m_data << v2, v1; |
| 83 | } |
| 84 | } |
| 85 | virtual ~Duplet() = default; |
| 86 | |
| 87 | inline virtual int hash() const { |
| 88 | // Magic primes (p1, p2) from the following paper. |
| 89 | // "Optimized Spacial Hashing for Collision Detection of |
| 90 | // Deformable Objects" by Teschner et al. (VMV 2003) |
| 91 | constexpr int p1 = 73856093; |
| 92 | constexpr int p2 = 19349663; |
| 93 | return (Parent::m_data.coeff(0)*p1) ^ (Parent::m_data.coeff(1)*p2); |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | class Triplet : public Multiplet<int, 3> { |
| 98 | public: |