diff --git a/ExtraTypes.cpp b/ExtraTypes.cpp index e5897b585985943002c64b57c6e4e5ad301011f6..eb054d612a24231318d4c16d3a1d9d512cc1ab07 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