jianbaoxia
CAD master
I note there are Hashcode function in "asiAlgo_AAG.h" The code:
I'm curious, why the HashCode design like this, I never use write hashcode by myself before, I was learn it in data structure book.
Is the design has some relations with the "TColStd_PackedMapOfInteger", which was used in AAG.
Actually, after read Anatomy of CAD feature and code in "asiAlgo_AAG::init()" I still have no idea what's the usage of TColStd_PackedMapOfInteger.
Code:
//! Arc between two nodes of AAG. The arc is the explicit representation
//! for adjacency relation.
struct t_arc
{
t_topoId F1; //!< First face.
t_topoId F2; //!< Second face.
//! ctor default.
t_arc() : F1(0), F2(0) {}
//! ctor with parameters.
t_arc(const t_topoId _F1, const t_topoId _F2) : F1(_F1), F2(_F2) {}
//! \return hash code for the arc.
static int HashCode(const t_arc& arc, const int upper)
{
int key = arc.F1 + arc.F2;
key += (key << 10);
key ^= (key >> 6);
key += (key << 3);
key ^= (key >> 11);
return (key & 0x7fffffff) % upper;
}
//! \return true if two links are equal.
static int IsEqual(const t_arc& arc1, const t_arc& arc2)
{
return ( (arc1.F1 == arc2.F1) && (arc1.F2 == arc2.F2) ) ||
( (arc1.F2 == arc2.F1) && (arc1.F1 == arc2.F2) );
}
};
I'm curious, why the HashCode design like this, I never use write hashcode by myself before, I was learn it in data structure book.
Is the design has some relations with the "TColStd_PackedMapOfInteger", which was used in AAG.
Actually, after read Anatomy of CAD feature and code in "asiAlgo_AAG::init()" I still have no idea what's the usage of TColStd_PackedMapOfInteger.