// File: GEOMAlgo_PassKey.cxx // Created: // Author: Peter KURNEV // #include #include #include #include #ifdef WNT #pragma warning( disable : 4101) #endif static void SortShell(const int n, int* a); static Standard_Integer NormalizedId(const Standard_Integer aId, const Standard_Integer aDiv); //======================================================================= //function : //purpose : //======================================================================= GEOMAlgo_PassKey::GEOMAlgo_PassKey() { Clear(); } //======================================================================= //function :Assign //purpose : //======================================================================= GEOMAlgo_PassKey& GEOMAlgo_PassKey::Assign(const GEOMAlgo_PassKey& anOther) { myNbIds=anOther.myNbIds; myNbMax=anOther.myNbMax; mySum=anOther.mySum; memcpy(myIds, anOther.myIds, sizeof(myIds)); return *this; } //======================================================================= //function :Clear //purpose : //======================================================================= void GEOMAlgo_PassKey::Clear() { Standard_Integer i; // myNbIds=0; myNbMax=8; mySum=0; for (i=0; i myNbMax) { return; } // myNbIds=aNb; mySum=0; i=myNbMax-myNbIds; aIt.Initialize(aLI); for (; aIt.More(); aIt.Next(), ++i) { anId=aIt.Value(); myIds[i]=anId; aIdN=NormalizedId(anId, myNbIds); mySum+=aIdN; } // Compute(); } //======================================================================= //function :Id //purpose : //======================================================================= Standard_Integer GEOMAlgo_PassKey::Id(const Standard_Integer aIndex)const { if (aIndex < 0 || aIndex >= myNbMax) { return 0; } return myIds[aIndex]; } //======================================================================= //function :NbMax //purpose : //======================================================================= Standard_Integer GEOMAlgo_PassKey::NbMax()const { return myNbMax; } //======================================================================= //function :Compute //purpose : //======================================================================= void GEOMAlgo_PassKey::Compute() { SortShell(myNbIds, myIds+myNbMax-myNbIds); } //======================================================================= //function :IsEqual //purpose : //======================================================================= Standard_Boolean GEOMAlgo_PassKey::IsEqual(const GEOMAlgo_PassKey& anOther) const { Standard_Integer iIsEqual; Standard_Boolean bIsEqual; // iIsEqual=memcmp(myIds, anOther.myIds, sizeof(myIds)); bIsEqual=Standard_False; if (!iIsEqual) { bIsEqual=!bIsEqual; } return bIsEqual; } //======================================================================= //function :Key //purpose : //======================================================================= Standard_Address GEOMAlgo_PassKey::Key()const { return (Standard_Address)myIds; } //======================================================================= //function : HashCode //purpose : //======================================================================= Standard_Integer GEOMAlgo_PassKey::HashCode(const Standard_Integer Upper) const { //return (mySum % Upper); return ::HashCode(mySum, Upper); } //======================================================================= //function : Dump //purpose : //======================================================================= void GEOMAlgo_PassKey::Dump()const { Standard_Integer i; // printf(" PassKey: {"); for (i=0; iaTresh) { aIdRet=aId%aTresh; } return aIdRet; } //======================================================================= // function: SortShell // purpose : //======================================================================= void SortShell(const int n, int* a) { int x, nd, i, j, l, d=1; // while(d<=n) { d*=2; } // while (d) { d=(d-1)/2; // nd=n-d; for (i=0; i -1) goto m30; }//if (a[l] < a[j]){ }//for (i=0; i