From 9e04f47eb80476594ac19643da12d35a60e1ed93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=9E=D1=80=D0=B5=D1=85?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Fri, 4 Dec 2020 18:15:08 +0000 Subject: [PATCH] Update ExtraTypes.cpp --- ExtraTypes.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ExtraTypes.cpp b/ExtraTypes.cpp index e5897b5..eb054d6 100644 --- a/ExtraTypes.cpp +++ b/ExtraTypes.cpp @@ -97,3 +97,24 @@ bool Edge::operator==(const Edge& right_edge) const { bool Edge::operator<(const Edge& right_edge) const { return c_id < right_edge.c_id; } + +template < typename _T > +inline void hashCombine ( std::size_t & o_seed , const _T & p_val) +{ + o_seed ^= std :: hash <_T >() (p_val) + 0x9e3779b9 + (o_seed << 6) + (o_seed >> 2) ; +} + +size_t hash_u_set::operator()(const s &x) const{ + std :: size_t seed = 0; + int a[] = {x.f_id, x.l_id, x.c_id}; + if(a[0] > a[1]) + a[0].swap(a[1]); + if(a[1] > a[2]) + a[1].swap(a[2]); + if(a[0] > a[1]) + a[0].swap(a[1]); + hashCombine(seed, a[0]); + hashCombine(seed, a[1]); + hashCombine(seed, a[2]); + return seed; +} \ No newline at end of file -- GitLab