return (myIndex1 == theOther.myIndex1 && myIndex2 == theOther.myIndex2) ||
(myIndex1 == theOther.myIndex2 && myIndex2 == theOther.myIndex1);
}
- //
- //! Returns hash code
- Standard_Integer HashCode (const Standard_Integer theUpper) const
+
+ //! Computes a hash code for this pair, in the range [1, theUpperBound]
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_Integer HashCode (const Standard_Integer theUpperBound) const
{
- return ::HashCode(myIndex1 + myIndex2, theUpper);
+ return ::HashCode(myIndex1 + myIndex2, theUpperBound);
}
protected:
public:
DEFINE_STANDARD_ALLOC
-
- static Standard_Integer HashCode(const BOPDS_Pair& thePair,
- const Standard_Integer Upper)
+
+ //! Computes a hash code for the given pair, in the range [1, theUpperBound]
+ //! @param thePair the pair which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const BOPDS_Pair& thePair, const Standard_Integer theUpperBound)
{
- return thePair.HashCode(Upper);
+ return thePair.HashCode (theUpperBound);
}
-
+
static Standard_Boolean IsEqual(const BOPDS_Pair& thePair1,
const BOPDS_Pair& thePair2)
{
DEFINE_STANDARD_ALLOC
-
- static Standard_Integer HashCode (const BOPDS_Pave& aPave, const Standard_Integer Upper);
-
- static Standard_Boolean IsEqual (const BOPDS_Pave& aPave1, const BOPDS_Pave& aPave2);
+ //! Computes a hash code for the given pave, in the range [1, theUpperBound]
+ //! @param thePave the pave which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const BOPDS_Pave& thePave, Standard_Integer theUpperBound);
+
+ static Standard_Boolean IsEqual (const BOPDS_Pave& aPave1, const BOPDS_Pave& aPave2);
#include <BOPDS_Pave.hxx>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-inline
- Standard_Integer BOPDS_PaveMapHasher::HashCode(const BOPDS_Pave& aPave,
- const Standard_Integer Upper)
+inline Standard_Integer BOPDS_PaveMapHasher::HashCode (const BOPDS_Pave& thePave, const Standard_Integer theUpperBound)
{
- return ::HashCode(aPave.Index(), Upper);
+ return ::HashCode (thePave.Index(), theUpperBound);
}
+
//=======================================================================
//function :IsEqual
//purpose :
//! Auxiliary thread ID hasher.
struct Hasher
{
- static Standard_Integer HashCode(const Standard_ThreadId theKey,
- const Standard_Integer Upper)
+ //! Computes a hash code for the given thread identifier, in the range [1, theUpperBound]
+ //! @param theThreadId the thread identifier which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const Standard_ThreadId theThreadId, const Standard_Integer theUpperBound)
{
- return ::HashCode((Standard_Size)theKey, Upper);
+ return ::HashCode (theThreadId, theUpperBound);
}
static Standard_Boolean IsEqual(const Standard_ThreadId theKey1,
{
return myShape;
}
+
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-Standard_Integer BOPTools_Set::HashCode
- (const Standard_Integer theUpper)const
+Standard_Integer BOPTools_Set::HashCode (const Standard_Integer theUpperBound) const
{
- return ::HashCode(mySum, theUpper);
+ return ::HashCode (mySum, theUpperBound);
}
+
//=======================================================================
//function : IsEqual
//purpose :
Standard_EXPORT Standard_Integer NbShapes() const;
Standard_EXPORT Standard_Boolean IsEqual (const BOPTools_Set& aOther) const;
-
- Standard_EXPORT Standard_Integer HashCode (const Standard_Integer Upper) const;
-
+ //! Computes a hash code for this set, in the range [1, theUpperBound]
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT Standard_Integer HashCode (Standard_Integer theUpperBound) const;
protected:
public:
DEFINE_STANDARD_ALLOC
-
-
- static Standard_Integer HashCode (const BOPTools_Set& aSet, const Standard_Integer Upper);
-
- static Standard_Boolean IsEqual (const BOPTools_Set& aSet1, const BOPTools_Set& aSet2);
+
+ //! Computes a hash code for the given set, in the range [1, theUpperBound]
+ //! @param theSet the set which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const BOPTools_Set& theSet, Standard_Integer theUpperBound);
+
+ static Standard_Boolean IsEqual (const BOPTools_Set& aSet1, const BOPTools_Set& aSet2);
// commercial license or contractual agreement.
//#include <BOPTools_SetMapHasher.ixx>
+
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-inline Standard_Integer BOPTools_SetMapHasher::HashCode(const BOPTools_Set& theSS,
- const Standard_Integer Upper)
+inline Standard_Integer BOPTools_SetMapHasher::HashCode (const BOPTools_Set& theSet,
+ const Standard_Integer theUpperBound)
{
- return theSS.HashCode(Upper);
+ return theSet.HashCode (theUpperBound);
}
+
//=======================================================================
//function :IsEqual
//purpose :
BRepMesh_DegreeOfFreedom myMovability;
};
-inline Standard_Integer HashCode(const BRepMesh_Edge& theEdge,
- const Standard_Integer theUpper)
+//! Computes a hash code for the given edge, in the range [1, theUpperBound]
+//! @param theEdge the edge which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const BRepMesh_Edge& theEdge, const Standard_Integer theUpperBound)
{
- return theEdge.HashCode(theUpper);
+ return theEdge.HashCode (theUpperBound);
}
#endif
return myLastNode;
}
- //! Returns hash code for this edge.
- //! @param theUpper upper index in the container.
- //! @return hash code.
- inline Standard_Integer HashCode(const Standard_Integer theUpper) const
+ //! Computes a hash code for this oriented edge, in the range [1, theUpperBound]
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ inline Standard_Integer HashCode (const Standard_Integer theUpperBound) const
{
- return ::HashCode(myFirstNode + myLastNode, theUpper);
+ return ::HashCode (myFirstNode + myLastNode, theUpperBound);
}
//! Checks this and other edge for equality.
Standard_Integer myLastNode;
};
-inline Standard_Integer HashCode(const BRepMesh_OrientedEdge& theEdge,
- const Standard_Integer theUpper)
+//! Computes a hash code for the given oriented edge, in the range [1, theUpperBound]
+//! @param theOrientedEdge the oriented edge which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const BRepMesh_OrientedEdge& theOrientedEdge, const Standard_Integer theUpperBound)
{
- return theEdge.HashCode(theUpper);
+ return theOrientedEdge.HashCode (theUpperBound);
}
#endif
{
myMovability = theMovability;
}
-
- //! Returns hash code for this triangle.
- //! @param theUpper upper index in the container.
- //! @return hash code.
- inline Standard_Integer HashCode(const Standard_Integer theUpper) const
+
+ //! Computes a hash code for this triangle, in the range [1, theUpperBound]
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ inline Standard_Integer HashCode (const Standard_Integer theUpperBound) const
{
- return ::HashCode(myEdges[0] + myEdges[1] + myEdges[2], theUpper);
+ return ::HashCode (myEdges[0] + myEdges[1] + myEdges[2], theUpperBound);
}
-
+
//! Checks for equality with another triangle.
//! @param theOther triangle to be checked against this one.
//! @return TRUE if equal, FALSE if not.
BRepMesh_DegreeOfFreedom myMovability;
};
-inline Standard_Integer HashCode(const BRepMesh_Triangle& theTriangle,
- const Standard_Integer theUpper)
+//! Computes a hash code for the given triangle, in the range [1, theUpperBound]
+//! @param theTriangle the triangle which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const BRepMesh_Triangle& theTriangle, const Standard_Integer theUpperBound)
{
- return theTriangle.HashCode(theUpper);
+ return theTriangle.HashCode (theUpperBound);
}
#endif
{
myMovability = theMovability;
}
-
- //! Returns hash code for this vertex.
- //! @param theUpper upper index in the container.
- //! @return hash code.
- inline Standard_Integer HashCode(const Standard_Integer Upper) const
+
+ //! Computes a hash code for this vertex, in the range [1, theUpperBound]
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ inline Standard_Integer HashCode(const Standard_Integer theUpperBound) const
{
- return ::HashCode(Floor(1e5 * myUV.X()) * Floor(1e5 * myUV.Y()), Upper);
+ return ::HashCode(Floor(1e5 * myUV.X()) * Floor(1e5 * myUV.Y()), theUpperBound);
}
//! Checks for equality with another vertex.
BRepMesh_DegreeOfFreedom myMovability;
};
-inline Standard_Integer HashCode(const BRepMesh_Vertex& me, const Standard_Integer Upper)
+//! Computes a hash code for the given vertex, in the range [1, theUpperBound]
+//! @param theVertex the vertex which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const BRepMesh_Vertex& theVertex, const Standard_Integer theUpperBound)
{
- return me.HashCode(Upper);
+ return theVertex.HashCode (theUpperBound);
}
#endif
Handle(Font_SystemFont) Find (const TCollection_AsciiString& theFontName) const;
public:
-
- //! Hash value, for Map interface.
- //! Based on Font Family, so that the whole family with different aspects can be found within the same bucket.
- static Standard_Integer HashCode (const Handle(Font_SystemFont)& theFont,
- const Standard_Integer theUpper)
+ //! Computes a hash code for the system font, in the range [1, theUpperBound]. Based on Font Family, so that the
+ //! whole family with different aspects can be found within the same bucket of some map
+ //! @param theHExtendedString the handle referred to extended string which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const Handle (Font_SystemFont) & theSystemFont,
+ const Standard_Integer theUpperBound)
{
- return ::HashCode (theFont->FontKey(), theUpper);
+ return ::HashCode (theSystemFont->FontKey(), theUpperBound);
}
//! Matching two instances, for Map interface.
Standard_EXPORT TCollection_AsciiString ToString() const;
public:
-
- //! Hash value, for Map interface.
- //! Based on Font Family, so that the whole family with different aspects can be found within the same bucket.
- static Standard_Integer HashCode (const Handle(Font_SystemFont)& theFont,
- const Standard_Integer theUpper)
+ //! Computes a hash code for the system font, in the range [1, theUpperBound]. Based on Font Family, so that the whole
+ //! family with different aspects can be found within the same bucket of some map
+ //! @param theSystemFont the system font which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const Handle (Font_SystemFont) & theSystemFont, const Standard_Integer theUpperBound)
{
- return ::HashCode (theFont->FontKey(), theUpper);
+ return ::HashCode (theSystemFont->FontKey(), theUpperBound);
}
//! Matching two instances, for Map interface.
return (theFirst == theSecond);
}
- static Standard_Integer HashCode(const Type* thePtr, Standard_Integer theUpper)
+ //! Computes a hash code for the given pointer, in the range [1, theUpperBound]
+ //! @param thePointer the pointer which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const Type* const thePointer, Standard_Integer theUpperBound)
{
- return ::HashCode(thePtr, theUpper);
+ return ::HashCode (thePointer, theUpperBound);
}
};
return (myIndex1 == theOther.myIndex1 && myIndex2 == theOther.myIndex2) ||
(myIndex1 == theOther.myIndex2 && myIndex2 == theOther.myIndex1);
}
- //
- //! Returns hash code
- Standard_Integer HashCode (const Standard_Integer theUpper) const
+
+ //! Computes a hash code for this couple, in the range [1, theUpperBound]
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_Integer HashCode (const Standard_Integer theUpperBound) const
{
- return ::HashCode(myIndex1 + myIndex2, theUpper);
+ return ::HashCode (myIndex1 + myIndex2, theUpperBound);
}
+
// Dump
Standard_EXPORT void Dump (const Standard_Integer v) const;
class IntPolyh_CoupleMapHasher
{
public:
-
- static Standard_Integer HashCode(const IntPolyh_Couple& theCouple,
- const Standard_Integer Upper)
+
+ //! Computes a hash code for the given couple, in the range [1, theUpperBound]
+ //! @param theCouple the couple which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const IntPolyh_Couple& theCouple, const Standard_Integer theUpperBound)
{
- return theCouple.HashCode(Upper);
+ return theCouple.HashCode (theUpperBound);
}
-
+
static Standard_Boolean IsEqual(const IntPolyh_Couple& theCouple1,
const IntPolyh_Couple& theCouple2)
{
DEFINE_STANDARD_ALLOC
-
- //! Returns a HasCode value for the Key <K> in the
- //! range 0..Upper.
- static Standard_Integer HashCode (const IntTools_CurveRangeSample& K, const Standard_Integer Upper);
-
+ //! Computes a hash code for the given key, in the range [1, theUpperBound]
+ //! @param theKey the key which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const IntTools_CurveRangeSample& theKey, const Standard_Integer theUpperBound);
+
//! Returns True when the two keys are the same. Two
//! same keys must have the same hashcode, the
//! contrary is not necessary.
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-inline Standard_Integer IntTools_CurveRangeSampleMapHasher::HashCode(const IntTools_CurveRangeSample& K,
- const Standard_Integer Upper) {
- return (K.GetDepth() % Upper);
+//=======================================================================
+// function : HashCode
+// purpose :
+//=======================================================================
+inline Standard_Integer IntTools_CurveRangeSampleMapHasher::HashCode (const IntTools_CurveRangeSample& theKey,
+ const Standard_Integer theUpperBound)
+{
+ return ::HashCode(theKey.GetDepth(), theUpperBound);
}
-
+
inline Standard_Boolean IntTools_CurveRangeSampleMapHasher::IsEqual(const IntTools_CurveRangeSample& S1,
const IntTools_CurveRangeSample& S2) {
return S1.IsEqual(S2);
DEFINE_STANDARD_ALLOC
-
- //! Returns a HasCode value for the Key <K> in the
- //! range 0..Upper.
- static Standard_Integer HashCode (const IntTools_SurfaceRangeSample& K, const Standard_Integer Upper);
-
+ //! Computes a hash code for the given key, in the range [1, theUpperBound]
+ //! @param theKey the key which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const IntTools_SurfaceRangeSample& theKey, Standard_Integer theUpperBound);
+
//! Returns True when the two keys are the same. Two
//! same keys must have the same hashcode, the
//! contrary is not necessary.
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-inline Standard_Integer IntTools_SurfaceRangeSampleMapHasher::HashCode(const IntTools_SurfaceRangeSample& K,
- const Standard_Integer Upper) {
-// return (((K.GetDepthU() % Upper) ^ (K.GetDepthV() % Upper)) % Upper);
- return ((K.GetIndexU() * K.GetIndexV()) % Upper);
+//=======================================================================
+// function : HashCode
+// purpose :
+//=======================================================================
+inline Standard_Integer IntTools_SurfaceRangeSampleMapHasher::HashCode (const IntTools_SurfaceRangeSample& theKey,
+ const Standard_Integer theUpperBound)
+{
+ // return (((K.GetDepthU() % Upper) ^ (K.GetDepthV() % Upper)) % Upper);
+ return ::HashCode (theKey.GetIndexU() * theKey.GetIndexV(), theUpperBound);
}
-
+
inline Standard_Boolean IntTools_SurfaceRangeSampleMapHasher::IsEqual(const IntTools_SurfaceRangeSample& S1,
const IntTools_SurfaceRangeSample& S2) {
return S1.IsEqual(S2);
#include <TCollection_AsciiString.hxx>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-Standard_Integer Interface_MapAsciiStringHasher::HashCode(const TCollection_AsciiString& K,
- const Standard_Integer Upper)
+Standard_Integer Interface_MapAsciiStringHasher::HashCode (const TCollection_AsciiString& theAsciiString,
+ const Standard_Integer theUpperBound)
{
- return ::HashCode(K.ToCString(),Upper);
+ return ::HashCode (theAsciiString.ToCString(), theAsciiString.Length(), theUpperBound);
}
//=======================================================================
DEFINE_STANDARD_ALLOC
-
- Standard_EXPORT static Standard_Integer HashCode (const TCollection_AsciiString& K, const Standard_Integer Upper);
-
+ //! Computes a hash code for the given ASCII string, in the range [1, theUpperBound]
+ //! @param theAsciiString the ASCII string which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT static Standard_Integer HashCode (const TCollection_AsciiString& theAsciiString,
+ Standard_Integer theUpperBound);
+
Standard_EXPORT static Standard_Boolean IsEqual (const TCollection_AsciiString& K1, const TCollection_AsciiString& K2);
public:
DEFINE_STANDARD_ALLOC
-
-
- static Standard_Integer HashCode (const MAT2d_BiInt& Key1, const Standard_Integer Upper);
-
- static Standard_Boolean IsEqual (const MAT2d_BiInt& Key1, const MAT2d_BiInt& Key2);
+
+ //! Computes a hash code for the given key, in the range [1, theUpperBound]
+ //! @param theKey the key which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const MAT2d_BiInt& theKey, const Standard_Integer theUpperBound);
+
+ static Standard_Boolean IsEqual (const MAT2d_BiInt& Key1, const MAT2d_BiInt& Key2);
#include <TColStd_MapIntegerHasher.hxx>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-inline Standard_Integer MAT2d_MapBiIntHasher::HashCode
-(const MAT2d_BiInt& Key1, const Standard_Integer upper)
+inline Standard_Integer MAT2d_MapBiIntHasher::HashCode (const MAT2d_BiInt& theKey, const Standard_Integer theUpperBound)
{
- return TColStd_MapIntegerHasher::HashCode(Key1.FirstIndex(),upper);
+ return TColStd_MapIntegerHasher::HashCode (theKey.FirstIndex(), theUpperBound);
}
//=======================================================================
//! Provides symmetric hash methods pair of integers.
struct MeshVS_SymmetricPairHasher
{
- static Standard_Integer HashCode (const MeshVS_NodePair& thePair, const Standard_Integer theMaxCode)
+ //! Computes a hash code for the node pair, in the range [1, theUpperBound]
+ //! @param theNodePair the node pair which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const MeshVS_NodePair& theNodePair, const Standard_Integer theUpperBound)
{
- return ((thePair.first + thePair.second) & 0x7FFFFFFF) % theMaxCode + 1;
+ return ::HashCode(theNodePair.first + theNodePair.second, theUpperBound);
}
static Standard_Boolean IsEqual (const MeshVS_NodePair& thePair1, const MeshVS_NodePair& thePair2)
//================================================================
-// Function : HashCode
-// Purpose :
+// function : HashCode
+// purpose :
//================================================================
-Standard_Integer HashCode ( const MeshVS_TwoColors& theKey,
- const Standard_Integer theUpper)
+Standard_Integer HashCode (const MeshVS_TwoColors& theKey, const Standard_Integer theUpperBound)
{
#define MESHPRS_HASH_BYTE(val) { \
aHash += (val); \
aHash += (aHash << 10); \
aHash ^= (aHash >> 6); \
}
- Standard_Integer aHash = 0;
+ unsigned int aHash = 0;
MESHPRS_HASH_BYTE (theKey.r1)
MESHPRS_HASH_BYTE (theKey.g1)
MESHPRS_HASH_BYTE (theKey.b1)
aHash += (aHash << 3);
aHash ^= (aHash >> 11);
aHash += (aHash << 15);
- return (( aHash & 0x7fffffff ) % theUpper) + 1;
+ return HashCode(aHash, theUpperBound);
#undef MESHPRS_HASH_BYTE
}
} MeshVS_TwoColors;
-Standard_EXPORT Standard_Integer HashCode ( const MeshVS_TwoColors& theKey,
- const Standard_Integer theUpper );
+//! Computes a hash code for the key, in the range [1, theUpperBound]
+//! @param theKey the key which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+Standard_EXPORT Standard_Integer HashCode (const MeshVS_TwoColors& theKey, Standard_Integer theUpperBound);
Standard_EXPORT Standard_Boolean IsEqual (const MeshVS_TwoColors& K1,
const MeshVS_TwoColors& K2 );
: First(aFirst), Second(aSecond) {}
};
-//================================================================
-// Function : HashCode
-// Purpose :
-//================================================================
-
-inline Standard_Integer HashCode( const MeshVS_TwoNodes& obj,
- const Standard_Integer Upper )
+//! Computes a hash code for two nodes, in the range [1, theUpperBound]
+//! @param theTwoNodes the object of structure containing two IDs which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const MeshVS_TwoNodes& theTwoNodes, const Standard_Integer theUpperBound)
{
- // symmetrical with respect to obj.First and obj.Second
- const Standard_Integer aKey = obj.First + obj.Second;
- return HashCode (aKey, Upper);
+ // symmetrical with respect to theTwoNodes.First and theTwoNodes.Second
+ const Standard_Integer aKey = theTwoNodes.First + theTwoNodes.Second;
+ return HashCode (aKey, theUpperBound);
}
//================================================================
#include <MoniTool_Element.hxx>
#include <MoniTool_ElemHasher.hxx>
-Standard_Integer MoniTool_ElemHasher::HashCode
- (const Handle(MoniTool_Element)& K, const Standard_Integer Upper)
+//============================================================================
+// function : HashCode
+// purpose :
+//============================================================================
+Standard_Integer MoniTool_ElemHasher::HashCode (const Handle (MoniTool_Element) & theElement,
+ const Standard_Integer theUpperBound)
{
- return ((K->GetHashCode() - 1) % Upper) + 1;
+ return ::HashCode(theElement->GetHashCode() - 1, theUpperBound);
}
Standard_Boolean MoniTool_ElemHasher::IsEqual
DEFINE_STANDARD_ALLOC
-
- //! Returns a HashCode in the range <0,Upper> for a Element :
- //! asks the Element its HashCode then transforms it to be in the
- //! required range
- Standard_EXPORT static Standard_Integer HashCode (const Handle(MoniTool_Element)& K, const Standard_Integer Upper);
-
+ //! Returns hash code for the given element, in the range [1, theUpperBound].
+ //! Asks theElement its HashCode, then transforms it to be in the required range.
+ //! @param theElement the element which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT static Standard_Integer HashCode (const Handle (MoniTool_Element) & theElement,
+ Standard_Integer theUpperBound);
+
//! Returns True if two keys are the same.
//! The test does not work on the Elements themselves but by
//! calling their methods Equates
DEFINE_STANDARD_ALLOC
-
- //! Returns a HasCode value for the CString <Str> in the
- //! range 0..Upper.
- //! Default ::HashCode(Str,Upper)
- static Standard_Integer HashCode (const Standard_CString Str, const Standard_Integer Upper);
-
+ //! Returns hash code for the given string, in the range [1, theUpperBound]
+ //! @param theString the string which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (Standard_CString theString, Standard_Integer theUpperBound);
+
//! Returns True when the two CString are the same. Two
//! same strings must have the same hashcode, the
//! contrary is not necessary.
#include <string.h>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-
-inline Standard_Integer MoniTool_MTHasher::HashCode(const Standard_CString Str,
- const Standard_Integer Upper)
+inline Standard_Integer MoniTool_MTHasher::HashCode (const Standard_CString theString,
+ const Standard_Integer theUpperBound)
{
- return ::HashCode(Str,Upper);
+ return ::HashCode (theString, theUpperBound);
}
//=======================================================================
class Hasher
{
public:
- static Standard_Integer HashCode(const Key theKey, const Standard_Integer theUpper)
- { return theKey.Value % theUpper + 1; }
+ //! Returns hash code for the given key, in the range [1, theUpperBound]
+ //! @param theKey the key which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const Key theKey, const Standard_Integer theUpperBound)
+ {
+ return ::HashCode (theKey.Value, theUpperBound);
+ }
static Standard_Boolean IsEqual(const Key theOne, const Key theTwo)
{ return theOne.Value == theTwo.Value; }
return Standard_True;
}
- //! Compute hash code
- Standard_Integer HashCode (const Standard_Integer theUpper) const
+ //! Returns hash code for this cell, in the range [1, theUpperBound]
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_Integer HashCode (const Standard_Integer theUpperBound) const
{
// number of bits per each dimension in the hash code
- Standard_Integer aDim = Standard_Integer(index.Size());
- const Standard_Size aShiftBits = (BITS(long)-1) / aDim;
- long aCode=0;
- for (int i=0; i < aDim; i++)
- aCode = ( aCode << aShiftBits ) ^ index[i];
- return (unsigned)aCode % theUpper;
+ const std::size_t aDim = index.Size();
+ const std::size_t aShiftBits = (BITS (long) - 1) / aDim;
+ unsigned int aCode = 0;
+
+ for (std::size_t i = 0; i < aDim; ++i)
+ {
+ aCode = (aCode << aShiftBits) ^ index[i];
+ }
+
+ return ::HashCode(aCode, theUpperBound);
}
public:
NCollection_LocalArray<long, 10> index;
ListNode *Objects;
};
+
+ //! Returns hash code for the given cell, in the range [1, theUpperBound]
+ //! @param theCell the cell object which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ friend Standard_Integer HashCode (const Cell& theCell, const Standard_Integer theUpperBound)
+ {
+ return theCell.HashCode (theUpperBound);
+ }
- // definition of global functions is needed for map
- friend Standard_Integer HashCode (const Cell &aCell, const Standard_Integer theUpper)
- { return aCell.HashCode(theUpper); }
friend Standard_Boolean IsEqual (const Cell &aCell1, const Cell &aCell2)
{ return aCell1.IsEqual(aCell2); }
//purpose : Function is required to call the global function HashCode.
//=======================================================================
-template <class TheKeyType>
-inline Standard_Integer HashCode_Proxy (const TheKeyType& theKey,
- const Standard_Integer Upper)
+//! Returns hash code for the given key, in the range [1, theUpperBound]
+//! @tparam TheKeyType the type of the given key
+//! @param theKey the key which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+template <class TheKeyType>
+inline Standard_Integer HashCode_Proxy (const TheKeyType& theKey, const Standard_Integer theUpperBound)
{
- return HashCode (theKey, Upper);
+ return HashCode (theKey, theUpperBound);
}
//=======================================================================
*/
template <class TheKeyType> class NCollection_DefaultHasher {
public:
- //
- static Standard_Integer HashCode(const TheKeyType& theKey,
- const Standard_Integer Upper) {
- return HashCode_Proxy(theKey, Upper);
+ //! Returns hash code for the given key, in the range [1, theUpperBound]
+ //! @param theKey the key which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const TheKeyType& theKey, const Standard_Integer theUpperBound)
+ {
+ return HashCode_Proxy (theKey, theUpperBound);
}
+
//
static Standard_Boolean IsEqual(const TheKeyType& theKey1,
const TheKeyType& theKey2) {
adata->func = myFunc;
// then try to create a new thread
-
+ DWORD aThreadId = DWORD();
myThread = CreateThread ( NULL, WNTStackSize, WNTthread_func,
- adata, 0, &myThreadId );
+ adata, 0, &aThreadId );
+ myThreadId = aThreadId;
if ( myThread )
SetThreadPriority (myThread, myPriority);
else {
}
else
{
- myThreadId = myThread;
+ myThreadId = (Standard_ThreadId)myThread;
}
#endif
return myThread != 0;
#ifdef _WIN32
return GetCurrentThreadId();
#else
- return pthread_self();
+ return (Standard_ThreadId)pthread_self();
#endif
}
TColStd_PackedMapOfInteger myHangIndices;
};
-/**
- * HashCode method is needed for maps
- */
-inline Standard_Integer HashCode(const Poly_MakeLoops::Link& theKey,
- int theLimit)
+//! Computes a hash code for the given link, in the range [1, theUpperBound]
+//! @param theLink the link which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const Poly_MakeLoops::Link& theLink, const Standard_Integer theUpperBound)
{
- return HashCode(theKey.node1 + theKey.node2, theLimit);
+ return HashCode (theLink.node1 + theLink.node2, theUpperBound);
}
/**
DEFINE_HSEQUENCE(QANCollection_HSequenceFunc,QANCollection_SequenceFunc)
// HashCode and IsEquel must be defined for key types of maps
-Standard_Integer HashCode(const gp_Pnt thePnt, int theUpper)
+
+//! Computes a hash code for the point, in the range [1, theUpperBound]
+//! @param thePoint the point which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+Standard_Integer HashCode (const gp_Pnt& thePoint, int theUpperBound)
{
- return HashCode(thePnt.X(),theUpper);
+ return HashCode (thePoint.X(), theUpperBound);
}
Standard_Boolean IsEqual(const gp_Pnt& theP1, const gp_Pnt& theP2)
//! Hasher of Quantity_Color.
struct Quantity_ColorHasher
{
- //! Returns hash code for the given color.
+ //! Returns hash code for the given RGB color, in the range [1, theUpperBound]
+ //! @param theColor the RGB color object which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing range must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
static Standard_Integer HashCode (const Quantity_Color& theColor,
- const Standard_Integer theUpper)
+ const Standard_Integer theUpperBound)
{
Standard_Integer aRed = Standard_Integer (255 * theColor.Red());
Standard_Integer aGreen = Standard_Integer (255 * theColor.Green());
Standard_Integer aBlue = Standard_Integer (255 * theColor.Blue());
- Standard_Integer aHash = 0;
+ unsigned int aHash = 0;
+
updateHash (aHash, aRed);
updateHash (aHash, aGreen);
updateHash (aHash, aBlue);
aHash += (aHash << 3);
aHash ^= (aHash >> 11);
aHash += (aHash << 15);
- return ((aHash & 0x7fff) % theUpper) + 1;
+
+ return IntegerHashCode(aHash, 0x7fff, theUpperBound);
}
//! Returns true if two colors are equal.
}
protected:
- static void updateHash (Standard_Integer& theHash,
- const Standard_Integer theValue)
+ static void updateHash (unsigned int& theHash, const Standard_Integer theValue)
{
theHash += theValue;
theHash += (theHash << 10);
struct Quantity_ColorRGBAHasher
{
- //! Returns hash code for the given color.
+ //! Returns hash code for the given RGBA color, in the range [1, theUpperBound]
+ //! @param theColor the RGBA color object which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
static Standard_Integer HashCode (const Quantity_ColorRGBA& theColor,
- const Standard_Integer theUpper)
+ const Standard_Integer theUpperBound)
{
const NCollection_Vec4<float>& aColor = theColor;
uint32_t aColor32 = (uint32_t(aColor.a() * 255.0f) << 24)
+ (uint32_t(aColor.b() * 255.0f) << 16)
+ (uint32_t(aColor.g() * 255.0f) << 8)
+ uint32_t(aColor.r() * 255.0f);
- return ((aColor32 & 0x7fffffff) % theUpper) + 1;
+ return ::HashCode(aColor32, theUpperBound);
}
//! Returns true if two colors are equal.
return (thePnt1 - thePnt2).SquareModulus() < Precision::SquareConfusion();
}
- static Standard_Integer HashCode (const gp_XYZ& thePnt, Standard_Integer theUpper)
+ //! Computes a hash code for the point, in the range [1, theUpperBound]
+ //! @param thePoint the point which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const gp_XYZ& thePoint, const Standard_Integer theUpperBound)
{
- return ::HashCode (thePnt.X() * M_LN10 + thePnt.Y() * M_PI + thePnt.Z() * M_E, theUpper);
+ return ::HashCode (thePoint.X() * M_LN10 + thePoint.Y() * M_PI + thePoint.Z() * M_E, theUpperBound);
}
private:
DEFINE_STANDARD_ALLOC
-
- //! Returns a HasCode value for the Key <K> in the
- //! range 0..Upper.
- static Standard_Integer HashCode (const gp_Pnt& Point, const Standard_Integer Upper);
-
+ //! Computes a hash code for the point, in the range [1, theUpperBound]
+ //! @param thePoint the point which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const gp_Pnt& thePoint, const Standard_Integer theUpperBound);
+
//! Returns True when the two keys are the same. Two
//! same keys must have the same hashcode, the
//! contrary is not necessary.
// commercial license or contractual agreement.
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-inline Standard_Integer STEPConstruct_PointHasher::HashCode
- (const gp_Pnt& point, const Standard_Integer Upper)
+inline Standard_Integer STEPConstruct_PointHasher::HashCode (const gp_Pnt& thePoint,
+ const Standard_Integer theUpperBound)
{
- union
- {
- Standard_Real R[3];
+ union
+ {
+ Standard_Real R[3];
Standard_Integer I[6];
- } U;
+ } U;
- point.Coord(U.R[0],U.R[1],U.R[2]);
-
- return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper);
- // return ::HashCode((U.I[0]>>4)+(U.I[1]>>3)+(U.I[2]>>2)+(U.I[3]>>1)+(U.I[4]>>4)+(U.I[5]>>3),Upper);
+ thePoint.Coord (U.R[0], U.R[1], U.R[2]);
+ return ::HashCode (U.I[0] / 23 + U.I[1] / 19 + U.I[2] / 17 + U.I[3] / 13 + U.I[4] / 11 + U.I[5] / 7, theUpperBound);
+ // return ::HashCode((U.I[0]>>4)+(U.I[1]>>3)+(U.I[2]>>2)+(U.I[3]>>1)+(U.I[4]>>4)+(U.I[5]>>3),theUpperBound);
}
-
Standard_ShortReal.hxx
Standard_Size.hxx
Standard_SStream.hxx
+Standard_Std.hxx
Standard_Stream.hxx
Standard_Strtod.cxx
Standard_ThreadId.hxx
#include <Standard_Integer.hxx>
-//============================================================================
-//==== HashCode : Returns a HashCode CString
-//============================================================================
-inline Standard_Integer HashCode (const Standard_Address Value,
- const Standard_Integer Upper)
+//! Returns a hash code of the given memory pointer
+//! @param thePointer the memory pointer which hash code it to be computed
+//! @param theUpperBound the upper bound of the range a resulting hash code must be within
+//! @return a value of a computed hash code, in range [1, UpperBound]
+inline Standard_Integer HashCode (const void* const thePointer, const Standard_Integer theUpperBound)
{
- union {Standard_Address L ;
- Standard_Integer I[2] ;} U ;
- U.I[0] = 0 ;
- U.I[1] = 0 ;
- U.L = Value;
- return HashCode( ( ( U.I[0] ^ U.I[1] ) & 0x7fffffff ) , Upper ) ;
+ union
+ {
+ const void* L;
+ Standard_Integer I[2];
+ } U;
+
+ U.I[0] = 0;
+ U.I[1] = 0;
+ U.L = thePointer;
+
+ return HashCode (U.I[0] ^ U.I[1], theUpperBound);
}
//============================================================================
#include <stdarg.h>
//============================================================================
-//==== HashCode of a CString
+// function : HashCode
+// purpose :
//============================================================================
-Standard_Integer HashCode (const Standard_CString Value,
- const Standard_Integer Upper )
+Standard_Integer HashCode (const Standard_CString theString, const Standard_Integer theUpperBound)
{
- Standard_Integer aLen = (Standard_Integer)strlen(Value);
- return HashCode (HashCodes (Value, aLen), Upper);
+ const Standard_Integer aLength = static_cast<Standard_Integer> (strlen (theString));
+
+ return HashCode (theString, aLength, theUpperBound);
}
//============================================================================
-//==== HashCode of a CString
+// function : HashCodes
+// purpose :
//============================================================================
-Standard_Integer HashCodes (const Standard_CString Value,
- const Standard_Integer Len)
+Standard_Integer HashCodes (const Standard_CString theString, const Standard_Integer theLength)
{
// compute DJB2 hash of a string
- Standard_Integer hash = 0;
- const Standard_Character *c = Value;
- for (Standard_Integer i = 0; i < Len; i++, c++)
+ unsigned int hash = 0;
+ const Standard_Character* c = theString;
+
+ for (Standard_Integer i = 0; i < theLength; ++i, ++c)
{
/* hash = hash * 33 ^ c */
hash = ((hash << 5) + hash) ^ (*c);
}
- return hash;
+ return static_cast<Standard_Integer>(hash);
}
//======================================================================
#include <Standard_Integer.hxx>
-//! Returns bounded hash code for a null-terminated string, in range [1, theUpper]
-Standard_EXPORT Standard_Integer HashCode (const Standard_CString theStr, const Standard_Integer theUpper);
-
-//! Returns 32-bit hash code for the first theLen characters in the string theStr
-Standard_EXPORT Standard_Integer HashCodes (const Standard_CString theStr, const Standard_Integer theLen);
-
-//! Returns bounded hash code for the first theLen characters in
-//! the string theStr, in range [1, theUpper]
-inline Standard_Integer HashCode (const Standard_CString theStr,
- const Standard_Integer theLen,
- const Standard_Integer theUpper)
+//! Returns bounded hash code for the null-terminated string, in the range [1, theUpperBound]
+//! @param theString the null-terminated string which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+Standard_EXPORT Standard_Integer HashCode (Standard_CString theString, Standard_Integer theUpperBound);
+
+//! Returns 32-bit hash code for the first theLen characters in the string theStr.
+//! The result is unbound (may be not only positive, but also negative)
+//! @param theString the string which hash code is to be computed
+//! @param theLength the length of the given string
+//! @return a computed hash code of the given string
+Standard_EXPORT Standard_Integer HashCodes (Standard_CString theString, Standard_Integer theLength);
+
+//! Returns bounded hash code for the first theLength characters in the string theString, in the range [1, theUpperBound]
+//! @param theString the string which hash code is to be computed
+//! @param theLength the length of the initial substring of the given string which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code of the given string
+inline Standard_Integer HashCode (const Standard_CString theString,
+ const Standard_Integer theLength,
+ const Standard_Integer theUpperBound)
{
// return (Abs( HashCodes( Value , Len ) ) % Upper ) + 1 ;
- return HashCode (HashCodes (theStr, theLen), theUpper);
+ return HashCode (HashCodes (theString, theLength), theUpperBound);
}
//! Returns Standard_True if two strings are equal
static inline Standard_ThreadId GetThreadID()
{
#ifndef _WIN32
- return pthread_self();
+ return (Standard_ThreadId)pthread_self();
#else
return GetCurrentThreadId();
#endif
// commercial license or contractual agreement.
#include <Standard_ExtString.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_OStream.hxx>
+#include <Standard_Type.hxx>
-Standard_Integer HashCode (const Standard_ExtString Value,
- const Standard_Integer Upper)
+//============================================================================
+// function : HashCode
+// purpose :
+//============================================================================
+Standard_Integer HashCode (const Standard_ExtString theExtString, const Standard_Integer theUpperBound)
{
// compute SDBM hash of an ext string
- Standard_Integer hash = 0;
- for (const Standard_ExtCharacter *c = Value; *c; c++)
+ unsigned int hash = 0;
+
+ for (const Standard_ExtCharacter* c = theExtString; *c; ++c)
{
/* hash = hash * 33 ^ c */
hash = (*c) + (hash << 6) + (hash << 16) - hash;
}
- return HashCode (hash, Upper);
+ return HashCode (hash, theUpperBound);
}
#include <Standard_TypeDef.hxx>
-//============================================================================
-//==== HashCode : Returns a HashCode ExtString
-//============================================================================
-Standard_EXPORT Standard_Integer HashCode (const Standard_ExtString, const Standard_Integer);
+//! Computes a hash code for the given wide character string, in the range [1, theUpperBound]
+//! @param theExtString the wide character string which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+Standard_EXPORT Standard_Integer HashCode (Standard_ExtString theExtString, Standard_Integer theUpperBound);
#endif
aStream << sguid;
}
-Standard_Integer Standard_GUID::HashCode(const Standard_GUID& aGuid,const Standard_Integer Upper)
+//============================================================================
+// function : HashCode
+// purpose :
+//============================================================================
+Standard_Integer Standard_GUID::HashCode (const Standard_GUID& theGuid, const Standard_Integer theUpperBound)
{
- return aGuid.Hash(Upper);
+ return theGuid.Hash (theUpperBound);
}
Standard_Integer Standard_GUID::Hash(const Standard_Integer Upper) const
//! Hash function for GUID.
Standard_EXPORT Standard_Integer Hash (const Standard_Integer Upper) const;
-
- //! H method used by collections.
- Standard_EXPORT static Standard_Integer HashCode (const Standard_GUID& aguid, const Standard_Integer Upper);
+
+ //! Computes a hash code for the given GUID of the Standard_Integer type, in the range [1, theUpperBound]
+ //! @param theGUID the GUID which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT static Standard_Integer HashCode (const Standard_GUID& theGUID, Standard_Integer theUpperBound);
//! Returns True when the two GUID are the same.
Standard_EXPORT static Standard_Boolean IsEqual (const Standard_GUID& string1, const Standard_GUID& string2);
#define _Standard_Handle_HeaderFile
#include <Standard_Address.hxx>
+#include <Standard_Std.hxx>
#include <Standard_Stream.hxx>
#include <Standard_Transient.hxx>
-#include <type_traits>
-
class Standard_Transient;
//! Namespace opencascade is intended for low-level template classes and functions
namespace opencascade {
- //! Namespace opencascade::std includes templates from C++11 std namespace used by
- //! OCCT classes. These definitions are imported from std namespace, plus (on older
- //! compilers) from std::tr1, or implemented by custom code where neither std
- //! not std::tr1 provide necessary definitions.
- namespace std
- {
- // import all available standard stuff from std namespace
- using namespace ::std;
-
-// for old MSVC compiler, some standard templates are defined in std::tr1 namespace,
-// and some missing ones are implemented here
-#if(defined(_MSC_VER) && (_MSC_VER < 1600))
- using namespace ::std::tr1;
-
- // C++11 template class enable_if
- template<bool Test, class Type = void>
- struct enable_if
- {// type is undefined for assumed !_Test
- };
-
- template<class _Type>
- struct enable_if<true, _Type>
- {// type is _Type for _Test
- typedef _Type type;
- };
-
- template<bool Condition, typename TypeTrue, typename TypeFalse>
- struct conditional
- {
- typedef TypeTrue type;
- };
-
- template<typename TypeTrue, typename TypeFalse>
- struct conditional<false, TypeTrue, TypeFalse>
- {
- typedef TypeFalse type;
- };
-
-#endif
-
- } // namespace opencascade::std
-
- //! Trait yielding true if class T1 is base of T2 but not the same
- template <class T1, class T2, class Dummy = void>
- struct is_base_but_not_same : opencascade::std::is_base_of <T1, T2> {};
-
- //! Explicit specialization of is_base_of trait to workaround the
- //! requirement of type to be complete when T1 and T2 are the same.
- template <class T1, class T2>
- struct is_base_but_not_same <T1, T2, typename opencascade::std::enable_if <opencascade::std::is_same <T1, T2>::value>::type> : opencascade::std::false_type {};
-
//! Intrusive smart pointer for use with Standard_Transient class and its descendants.
//!
//! This class is similar to boost::intrusive_ptr<>. The reference counter
//! Define Handle() macro
#define Handle(Class) opencascade::handle<Class>
-//! Global method HashCode(), for use in hash maps
-template <class T>
-inline Standard_Integer HashCode (const Handle(T)& theHandle, const Standard_Integer theUpper)
+//! Computes a hash code for the standard handle, in the range [1, theUpperBound]
+//! @param TheTransientType the type of the object the handle is referred to
+//! @param theHandle the standard handle which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+template <class TheTransientType>
+Standard_Integer HashCode (const Handle (TheTransientType) & theHandle, const Standard_Integer theUpperBound)
{
- return ::HashCode (const_cast<Standard_Address>(static_cast<const void*>(theHandle.get())), theUpper);
+ return ::HashCode (theHandle.get(), theUpperBound);
}
//! For compatibility with previous versions of OCCT, define Handle_Class alias for opencascade::handle<Class>.
#ifndef _Standard_Integer_HeaderFile
#define _Standard_Integer_HeaderFile
+#include <Standard_Std.hxx>
#include <Standard_TypeDef.hxx>
#include <Standard_values.h>
return Value >= 0 ? Value : -Value;
}
-// ------------------------------------------------------------------
-// Hascode : Computes a hascoding value for a given Integer
-// ------------------------------------------------------------------
-inline Standard_Integer HashCode (const Standard_Integer theMe,
- const Standard_Integer theUpper)
-{
- //return (Abs (theMe) % theUpper) + 1;
- return ((theMe & 0x7fffffff ) % theUpper) + 1;
-}
-
-// ------------------------------------------------------------------
-// IsEqual : Returns Standard_True if two integers are equal
-// ------------------------------------------------------------------
-inline Standard_Boolean IsEqual (const Standard_Integer theOne,
- const Standard_Integer theTwo)
-{
- return theOne == theTwo;
-}
-
-// ------------------------------------------------------------------
-// Hascode : Computes a hascoding value for a given long long integer
-// ------------------------------------------------------------------
-inline Standard_Integer HashCode(const long long int theMe,
- const Standard_Integer theUpper)
-{
- return ((theMe & 0x7fffffffffffffff) % theUpper) + 1;
-}
-
-#if (defined(_LP64) || defined(__LP64__) || defined(_WIN64)) || defined(__APPLE__)
-// ------------------------------------------------------------------
-// Hascode : Computes a hascoding value for a given unsigned integer
-// ------------------------------------------------------------------
-inline Standard_Integer HashCode (const Standard_Utf32Char theMe,
- const Standard_Integer theUpper)
-{
- return ((theMe & 0x7fffffff ) % theUpper) + 1;
-}
-
-// ------------------------------------------------------------------
-// IsEqual : Returns Standard_True if two integers are equal
-// ------------------------------------------------------------------
-inline Standard_Boolean IsEqual (const Standard_Utf32Char theOne,
- const Standard_Utf32Char theTwo)
-{
- return theOne == theTwo;
-}
-#endif
-
// ------------------------------------------------------------------
// IsEven : Returns Standard_True if an integer is even
// ------------------------------------------------------------------
inline Standard_Integer IntegerSize()
{ return BITS(Standard_Integer); }
+
+//! Computes a hash code for the given value of some integer type, in range [1, theUpperBound]
+//! @tparam TheInteger the type of the integer which hash code is to be computed
+//! @param theValue the value of the TheInteger type which hash code is to be computed
+//! @param theMask the mask for the last bits of the value that are used in the computation of a hash code
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in range [1, theUpperBound]
+template <typename TheInteger>
+typename opencascade::std::enable_if<opencascade::is_integer<TheInteger>::value, Standard_Integer>::type
+IntegerHashCode (const TheInteger theValue,
+ const typename opencascade::disable_deduction<TheInteger>::type theMask,
+ const Standard_Integer theUpperBound)
+{
+ return static_cast<Standard_Integer> ((theValue & theMask) % theUpperBound + 1);
+}
+
+//! Computes a hash code for the given value of the Standard_Integer type, in range [1, theUpperBound]
+//! @param theValue the value of the Standard_Integer type which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in range [1, theUpperBound]
+inline Standard_Integer HashCode (const Standard_Integer theValue,
+ const Standard_Integer theUpperBound)
+{
+ // return (Abs (theMe) % theUpper) + 1;
+ return IntegerHashCode(theValue, IntegerLast(), theUpperBound);
+}
+
+// ------------------------------------------------------------------
+// IsEqual : Returns Standard_True if two integers are equal
+// ------------------------------------------------------------------
+inline Standard_Boolean IsEqual (const Standard_Integer theOne,
+ const Standard_Integer theTwo)
+{
+ return theOne == theTwo;
+}
+
+//! Computes a hash value for the given unsigned integer, in range [1, theUpperBound]
+//! @tparam TheUnsignedInteger the type of the given value (it is "unsigned int",
+//! and must not be the same as Standard_Size, because the overload of the HashCode function
+//! for Standard_Size type is already presented in Standard_Size.hxx)
+//! @param theValue the unsigned integer which hash code is to be computed
+//! @return a hash value computed for the given unsigned integer, in range [1, theUpperBound]
+template <typename TheUnsignedInteger>
+typename opencascade::std::enable_if<!opencascade::std::is_same<Standard_Size, unsigned int>::value
+ && opencascade::std::is_same<TheUnsignedInteger, unsigned int>::value,
+ Standard_Integer>::type
+HashCode (const TheUnsignedInteger theValue, const Standard_Integer theUpperBound)
+{
+ return HashCode (static_cast<Standard_Integer> (theValue), theUpperBound);
+}
+
+//! Computes a hash code for the given value of the "long long int" type, in range [1, theUpperBound]
+//! @param theValue the value of the "long long int" type which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in range [1, theUpperBound]
+inline Standard_Integer HashCode (const long long int theValue, const Standard_Integer theUpperBound)
+{
+ return IntegerHashCode(theValue, 0x7fffffffffffffff, theUpperBound);
+}
+
+#if (defined(_LP64) || defined(__LP64__) || defined(_WIN64)) || defined(__APPLE__)
+
+//! Computes a hash code for the given value of the Standard_Utf32Char type, in range [1, theUpperBound]
+//! @param theValue the value of the Standard_Utf32Char type which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in range [1, theUpperBound]
+inline Standard_Integer HashCode (const Standard_Utf32Char theValue,
+ const Standard_Integer theUpperBound)
+{
+ return IntegerHashCode(theValue, IntegerLast(), theUpperBound);
+}
+
+// ------------------------------------------------------------------
+// IsEqual : Returns Standard_True if two integers are equal
+// ------------------------------------------------------------------
+inline Standard_Boolean IsEqual (const Standard_Utf32Char theOne,
+ const Standard_Utf32Char theTwo)
+{
+ return theOne == theTwo;
+}
+
+#endif
+
#endif
static const Standard_Real ACosLimit = 1. + Epsilon(1.);
-// ------------------------------------------------------------------
-// Hascode : Computes a hascoding value for a given real
-// ------------------------------------------------------------------
-Standard_Integer HashCode(const Standard_Real me, const Standard_Integer Upper)
+//============================================================================
+// function : HashCode
+// purpose :
+//============================================================================
+Standard_Integer HashCode (const Standard_Real theReal, const Standard_Integer theUpperBound)
{
- if (Upper < 1){
- throw Standard_RangeError("Try to apply HashCode method with negative or null argument.");
+ if (theUpperBound < 1)
+ {
+ throw Standard_RangeError ("Try to apply HashCode method with negative or null argument.");
}
- union
- {
- Standard_Real R;
+ union
+ {
+ Standard_Real R;
Standard_Integer I[2];
- } U;
-// U.R = Abs(me); // Treat me = -0.0 ADN 27/11/97
- U.R = me ;
- return HashCode( ( U.I[0] ^ U.I[1] ) , Upper ) ;
- }
+ } U;
+
+ // U.R = Abs(me); // Treat me = -0.0 ADN 27/11/97
+ U.R = theReal;
+
+ return HashCode (U.I[0] ^ U.I[1], theUpperBound);
+}
//-------------------------------------------------------------------
// ACos : Returns the value of the arc cosine of a real
// ==================================
// Methods implemeted in Standard_Real.cxx
// ==================================
-Standard_EXPORT Standard_Integer HashCode (const Standard_Real, const Standard_Integer);
+
+//! Computes a hash code for the given real, in the range [1, theUpperBound]
+//! @param theReal the real value which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+Standard_EXPORT Standard_Integer HashCode (Standard_Real theReal, Standard_Integer theUpperBound);
Standard_EXPORT Standard_Real ACos (const Standard_Real );
Standard_EXPORT Standard_Real ACosApprox (const Standard_Real );
#include <Standard_Stream.hxx>
#include <Standard_OStream.hxx>
-// ------------------------------------------------------------------
-// Hascode : Computes a hascoding value for a given ShortReal
-// ------------------------------------------------------------------
-Standard_Integer HashCode(const Standard_ShortReal me, const Standard_Integer Upper)
+//============================================================================
+// function : HashCode
+// purpose :
+//============================================================================
+Standard_Integer HashCode (const Standard_ShortReal theShortReal, const Standard_Integer theUpperBound)
{
- if (Upper < 1){
- throw Standard_RangeError("Try to apply HashCode method with negative or null argument.");
+ if (theUpperBound < 1)
+ {
+ throw Standard_RangeError ("Try to apply HashCode method with negative or null argument.");
}
- union
- {
+ union
+ {
Standard_ShortReal R;
- Standard_Integer I;
- } U;
- U.R = me;
- return HashCode( U.I , Upper) ;
+ Standard_Integer I;
+ } U;
+ U.R = theShortReal;
+
+ return HashCode (U.I, theUpperBound);
}
// ==================================
// Methods implemeted in Standard_ShortReal.cxx
// ==================================
-Standard_EXPORT Standard_Integer HashCode (const Standard_ShortReal, const Standard_Integer);
+
+//! Computes a hash code for the given short real, in the range [1, theUpperBound]
+//! @param theShortReal the short real value which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+Standard_EXPORT Standard_Integer HashCode (Standard_ShortReal theShortReal, Standard_Integer theUpperBound);
//-------------------------------------------------------------------
// IsEqual : Returns Standard_True if two ShortReals are equal
#ifndef _Standard_Size_HeaderFile
#define _Standard_Size_HeaderFile
+#include <Standard_Integer.hxx>
+
// msv 26.05.2009: add HashCode and IsEqual functions
-// ------------------------------------------------------------------
-// Hascode : Computes a hashcoding value for a given value
-// ------------------------------------------------------------------
-inline Standard_Integer HashCode(const Standard_Size Val,
- const Standard_Integer Upper)
+//! Computes a hash code for the given value of the Standard_Size type, in the range [1, theUpperBound]
+//! @param theValue the value of the Standard_Size type which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const Standard_Size theValue, const Standard_Integer theUpperBound)
{
- Standard_Size aKey = ~Val + (Val << 18);
+ Standard_Size aKey = ~theValue + (theValue << 18);
aKey ^= (aKey >> 31);
aKey *= 21;
aKey ^= (aKey >> 11);
aKey += (aKey << 6);
aKey ^= (aKey >> 22);
- return (Standard_Integer(aKey & 0x7fffffff) % Upper) + 1;
+ return IntegerHashCode(aKey, IntegerLast(), theUpperBound);
}
// ------------------------------------------------------------------
--- /dev/null
+// Created on: 2019-03-27
+// Created by: Timur Izmaylov
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Standard_Std_HeaderFile
+#define _Standard_Std_HeaderFile
+
+
+#include <type_traits>
+
+
+//! Namespace opencascade is intended for low-level template classes and functions
+namespace opencascade
+{
+
+ //! Namespace opencascade::std includes templates from C++11 std namespace used by
+ //! OCCT classes. These definitions are imported from std namespace, plus (on older
+ //! compilers) from std::tr1, or implemented by custom code where neither std
+ //! not std::tr1 provide necessary definitions.
+ namespace std
+ {
+ // import all available standard stuff from std namespace
+ using namespace ::std;
+
+// for old MSVC compiler, some standard templates are defined in std::tr1 namespace,
+// and some missing ones are implemented here
+#if (defined(_MSC_VER) && (_MSC_VER < 1600))
+ using namespace ::std::tr1;
+
+ // C++11 template class enable_if
+ template <bool Test, class Type = void>
+ struct enable_if
+ { // type is undefined for assumed !_Test
+ };
+
+ template <class _Type>
+ struct enable_if<true, _Type>
+ { // type is _Type for _Test
+ typedef _Type type;
+ };
+
+ template <bool Condition, typename TypeTrue, typename TypeFalse>
+ struct conditional
+ {
+ typedef TypeTrue type;
+ };
+
+ template <typename TypeTrue, typename TypeFalse>
+ struct conditional<false, TypeTrue, TypeFalse>
+ {
+ typedef TypeFalse type;
+ };
+
+#endif
+
+ } // namespace std
+
+ //! Trait yielding true if class T1 is base of T2 but not the same
+ template <class T1, class T2, class Dummy = void>
+ struct is_base_but_not_same : opencascade::std::is_base_of<T1, T2>
+ {
+ };
+
+ //! Explicit specialization of is_base_of trait to workaround the
+ //! requirement of type to be complete when T1 and T2 are the same.
+ template <class T1, class T2>
+ struct is_base_but_not_same<T1,
+ T2,
+ typename opencascade::std::enable_if<opencascade::std::is_same<T1, T2>::value>::type>
+ : opencascade::std::false_type
+ {
+ };
+
+ //! The type trait that checks if the passed type is integer (it must be integral and not boolean)
+ //! @tparam TheInteger the checked type
+ template <typename TheInteger>
+ struct is_integer : std::integral_constant<bool,
+ opencascade::std::is_integral<TheInteger>::value
+ && !opencascade::std::is_same<TheInteger, bool>::value>
+ {
+ };
+
+ //! The auxiliary template that is used for template argument deduction in function templates. A function argument
+ //! which type is a template type parameter and it is not needed to be deducted must be declared using this class
+ //! template based on the type of some other template type parameter of a function template
+ //! @tparam TheType the type that is used as a function argument type to prevent its deduction
+ template <typename TheType>
+ struct disable_deduction
+ {
+ typedef TheType type;
+ };
+
+} // namespace opencascade
+
+#endif
#ifndef Standard_ThreadId_HeaderFile
#define Standard_ThreadId_HeaderFile
-// Platform-dependent definition of the thread identifier type
+#include <Standard_Size.hxx>
-#ifdef _WIN32
-
-#include <windows.h>
-typedef DWORD Standard_ThreadId;
-
-inline Standard_Integer HashCode(const Standard_ThreadId Value,
- const Standard_Integer Upper)
-{
- // Size of int == size of unsigned long == 4 for WIN32 and WIN64
- return HashCode((Standard_Integer)Value, Upper);
-}
-
-#else
-
-#include <pthread.h>
-typedef pthread_t Standard_ThreadId;
-
-#endif
+// Platform-independent definition of the thread identifier type
+typedef Standard_Size Standard_ThreadId;
#endif
mutable volatile Standard_Integer count;
};
-//! Global method HashCode(), for use in hash maps
-inline Standard_Integer HashCode (const Standard_Transient* theObject, const Standard_Integer theUpper)
+
+//! Computes a hash code for the given transient object, in the range [1, theUpperBound]
+//! @param theTransientObject the transient object which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const Standard_Transient* const theTransientObject,
+ const Standard_Integer theUpperBound)
{
- return ::HashCode ((Standard_Address*)theObject, theUpper);
+ return ::HashCode (static_cast<const void*> (theTransientObject), theUpperBound);
}
//! Definition of Handle_Standard_Transient as typedef for compatibility
// Value-based hasher for plain C string (char*)
struct CStringHasher
{
- static Standard_Integer HashCode (const Standard_CString& theKey, const Standard_Integer Upper)
+ //! Computes a hash code of the given Standard_CString, in the range [1, theUpperBound]
+ //! @param theKey the key which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const Standard_CString& theKey, const Standard_Integer theUpperBound)
{
- return ::HashCode (theKey, Upper);
+ return ::HashCode (theKey, theUpperBound);
}
static bool IsEqual (const Standard_CString& theKey1, const Standard_CString& theKey2)
{
#include <StepToTopoDS_CartesianPointHasher.hxx>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-Standard_Integer StepToTopoDS_CartesianPointHasher::HashCode
- (const Handle(StepGeom_CartesianPoint)& K, const Standard_Integer Upper)
+Standard_Integer StepToTopoDS_CartesianPointHasher::HashCode (const Handle (StepGeom_CartesianPoint)
+ & theCartesianPoint,
+ const Standard_Integer theUpperBound)
{
- return ::HashCode(K,Upper);
+ return ::HashCode (theCartesianPoint, theUpperBound);
}
//=======================================================================
DEFINE_STANDARD_ALLOC
-
- //! Returns a HasCode value for the CartesianPoint
- Standard_EXPORT static Standard_Integer HashCode (const Handle(StepGeom_CartesianPoint)& K, const Standard_Integer Upper);
-
+ //! Computes a hash code for the cartesian point, in the range [1, theUpperBound]
+ //! @param theCartesianPoint the cartesian point which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT static Standard_Integer HashCode (const Handle (StepGeom_CartesianPoint) & theCartesianPoint,
+ Standard_Integer theUpperBound);
+
//! Returns True when the two CartesianPoint are the same
Standard_EXPORT static Standard_Boolean IsEqual (const Handle(StepGeom_CartesianPoint)& K1, const Handle(StepGeom_CartesianPoint)& K2);
#include <StepToTopoDS_PointPairHasher.hxx>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-Standard_Integer StepToTopoDS_PointPairHasher::HashCode
- (const StepToTopoDS_PointPair& P, const Standard_Integer Upper)
+Standard_Integer StepToTopoDS_PointPairHasher::HashCode (const StepToTopoDS_PointPair& thePointPair,
+ const Standard_Integer theUpperBound)
{
- return (::HashCode(P.myP1,Upper) + ::HashCode(P.myP2,Upper)) % Upper;
+ return ::HashCode (::HashCode (thePointPair.myP1, theUpperBound) + ::HashCode (thePointPair.myP2, theUpperBound),
+ theUpperBound);
}
//=======================================================================
DEFINE_STANDARD_ALLOC
-
- //! Returns a HasCode value for the PointPair
- Standard_EXPORT static Standard_Integer HashCode (const StepToTopoDS_PointPair& K, const Standard_Integer Upper);
+ //! Computes a hash code for the point pair, in the range [1, theUpperBound]
+ //! @param thePointPair the point pair which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT static Standard_Integer HashCode (const StepToTopoDS_PointPair& thePointPair, Standard_Integer theUpperBound);
//! Returns True when the two PointPair are the same
Standard_EXPORT static Standard_Boolean IsEqual (const StepToTopoDS_PointPair& K1, const StepToTopoDS_PointPair& K2);
*/
Standard_Integer FindNext (unsigned int& theMask) const;
- /**
- * Support of Map interface.
- */
- inline Standard_Integer HashCode (const Standard_Integer theUpper) const
+ //! Computes a hash code for this map in the range [1, theUpperBound]
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ inline Standard_Integer HashCode (const Standard_Integer theUpperBound) const
{
- return ::HashCode (Standard_Integer(myMask >> 5), theUpper);
+ return ::HashCode (myMask >> 5, theUpperBound);
}
/**
//! aString.Value(2) returns 'e'
Standard_EXPORT Standard_Character Value (const Standard_Integer where) const;
- //! Hash function for AsciiString
- //! (returns the same Integer value that the hash function for ExtendedString)
- static Standard_Integer HashCode (const TCollection_AsciiString& astring, const Standard_Integer Upper);
-
+ //! Computes a hash code for the given ASCII string, in the range [1, theUpperBound].
+ //! Returns the same integer value as the hash function for TCollection_ExtendedString
+ //! @param theAsciiString the ASCII string which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const TCollection_AsciiString& theAsciiString, Standard_Integer theUpperBound);
+
//! Returns True when the two strings are the same.
//! (Just for HashCode for AsciiString)
static Standard_Boolean IsEqual (const TCollection_AsciiString& string1, const TCollection_AsciiString& string2);
#include <Standard_OutOfRange.hxx>
#include <Standard_CString.hxx>
-//definition global methods for using in NCollection
-//------------------------------------------------------------------------
-// HashCode
-//------------------------------------------------------------------------
-inline Standard_Integer HashCode(const TCollection_AsciiString& astring,
- const Standard_Integer Upper)
+// definition global methods for using in NCollection
+
+//! Computes a hash code for the given ASCII string, in the range [1, theUpperBound]
+//! @param theAsciiString the ASCII string which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const TCollection_AsciiString& theAsciiString, const Standard_Integer theUpperBound)
{
- return TCollection_AsciiString::HashCode(astring,Upper);
+ return TCollection_AsciiString::HashCode (theAsciiString, theUpperBound);
}
return TCollection_AsciiString( *this , TCollection_AsciiString(other) ) ;
}
-//------------------------------------------------------------------------
-// HashCode
-//------------------------------------------------------------------------
-inline Standard_Integer TCollection_AsciiString::HashCode(const TCollection_AsciiString& astring,
- const Standard_Integer Upper)
+//============================================================================
+// function : HashCode
+// purpose :
+//============================================================================
+inline Standard_Integer TCollection_AsciiString::HashCode (const TCollection_AsciiString& theAsciiString,
+ const Standard_Integer theUpperBound)
{
- return ::HashCode(astring.ToCString(),Upper);
+ return ::HashCode (theAsciiString.ToCString(), theAsciiString.Length(), theUpperBound);
}
//! the bounds of this extended string.
Standard_EXPORT Standard_ExtCharacter Value (const Standard_Integer where) const;
- //! Returns a hashed value for the extended string within the range 1..theUpper.
+ //! Returns a hashed value for the extended string within the range 1 .. theUpper.
//! Note: if string is ASCII, the computed value is the same as the value computed with the HashCode function on a
//! TCollection_AsciiString string composed with equivalent ASCII characters.
+ //! @param theExtendedString the extended string which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
static Standard_Integer HashCode (const TCollection_ExtendedString& theString,
- const Standard_Integer theUpper)
+ const Standard_Integer theUpperBound)
{
- return ::HashCode (theString.ToExtString(), theUpper);
+ return ::HashCode (theString.ToExtString(), theUpperBound);
}
//! Returns true if the characters in this extended
};
-//! Compute hash code for extended string
-inline Standard_Integer HashCode (const TCollection_ExtendedString& theString,
- const Standard_Integer theUpper)
+//! Computes a hash code for the given extended string, in the range [1, theUpperBound]
+//! @param theExtendedString the extended string which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const TCollection_ExtendedString& theExtendedString,
+ const Standard_Integer theUpperBound)
{
- return TCollection_ExtendedString::HashCode (theString, theUpper);
+ return TCollection_ExtendedString::HashCode (theExtendedString, theUpperBound);
}
#endif // _TCollection_ExtendedString_HeaderFile
class TDF_LabelMapHasher
{
public:
-
- //! Returns a HasCode value for the Key <K> in the range 0..Upper.
- static Standard_Integer HashCode(const TDF_Label& aLab, const Standard_Integer Upper)
+ //! Computes a hash code for the given label, in the range [1, theUpperBound]
+ //! @param theLabel the label which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode(const TDF_Label& theLabel, const Standard_Integer theUpperBound)
{
- return ::HashCode((Standard_Address)aLab.myLabelNode, Upper);
+ return ::HashCode(theLabel.myLabelNode, theUpperBound);
}
//! Returns True when the two keys are the same. Two
//! Methods inline implimentation for HExtendedString
-inline Standard_Integer HashCode (const Handle(TCollection_HExtendedString)& theStr,
- const Standard_Integer theBnd)
+//! Computes a hash code for the given handle referred to extended string, in the range [1, theUpperBound]
+//! @param theHExtendedString the handle referred to extended string which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const Handle (TCollection_HExtendedString) & theHExtendedString,
+ const Standard_Integer theUpperBound)
{
- return TCollection_ExtendedString::HashCode(theStr->String(), theBnd);
+ return TCollection_ExtendedString::HashCode (theHExtendedString->String(), theUpperBound);
}
inline Standard_Boolean IsEqual (const Handle(TCollection_HExtendedString)& theStr1,
}
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-
-Standard_Integer TopLoc_Location::HashCode(const Standard_Integer upper) const
+Standard_Integer TopLoc_Location::HashCode (const Standard_Integer theUpperBound) const
{
// the HashCode computed for a Location is the bitwise exclusive or
// of values computed for each element of the list
// this value is biwise rotated by depth
// the use of depth avoids getting the same result for two permutated lists.
- Standard_Integer depth = 0;
- unsigned int h = 0;
+ Standard_Integer depth = 0;
+ unsigned int h = 0;
TopLoc_SListOfItemLocation items = myItems;
- while (items.More()) {
+ while (items.More())
+ {
depth += 3;
- unsigned int i = ::HashCode (items.Value().myDatum, upper);
- unsigned int j = ( (i + items.Value().myPower) <<depth);
- j = j>>(32-depth) | j<<depth;
+ unsigned int i = ::HashCode (items.Value().myDatum, theUpperBound);
+ unsigned int j = ((i + items.Value().myPower) << depth);
+ j = j >> (32 - depth) | j << depth;
h ^= j;
- items.Next();
+ items.Next ();
}
- return h % upper;
+ return ::HashCode (h, theUpperBound);
}
//=======================================================================
//! returns Identity. <pwr> can be lower than zero
//! (usual meaning for powers).
Standard_EXPORT Standard_NODISCARD TopLoc_Location Powered (const Standard_Integer pwr) const;
-
- //! Returns a hashed value for this local coordinate system.
- //! This value is used, with map tables, to store and
- //! retrieve the object easily, and is in the range [ 1..Upper ].
- Standard_EXPORT Standard_Integer HashCode (const Standard_Integer Upper) const;
+
+ //! Returns a hashed value for this local coordinate system. This value is used, with map tables, to store and
+ //! retrieve the object easily, and is in the range [1, theUpperBound].
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT Standard_Integer HashCode (Standard_Integer theUpperBound) const;
//! Returns true if this location and the location Other
//! have the same elementary data, i.e. contain the same
#include <TopLoc_Location.lxx>
-
-inline Standard_Integer HashCode(const TopLoc_Location& me,const Standard_Integer Upper) {
- return me.HashCode(Upper);
+//! Computes a hash code for the given location, in the range [1, theUpperBound]
+//! @param theLocation the location which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const TopLoc_Location& theLocation, const Standard_Integer theUpperBound)
+{
+ return theLocation.HashCode (theUpperBound);
}
inline void ShallowDump(const TopLoc_Location& me,Standard_OStream& S) {
DEFINE_STANDARD_ALLOC
-
- //! Returns a HasCode value for the Key <K> in the
- //! range 0..Upper.
- static Standard_Integer HashCode (const TopoDS_Shape& S, const Standard_Integer Upper);
-
+ //! Computes a hash code for the given shape, in the range [1, theUpperBound]
+ //! @param theShape the shape which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const TopoDS_Shape& theShape, const Standard_Integer theUpperBound);
+
//! Returns True when the two keys are equal. Two same
//! keys must have the same hashcode, the contrary is
//! not necessary.
#include <TopoDS_Shape.hxx>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-inline Standard_Integer TopTools_OrientedShapeMapHasher::HashCode
- (const TopoDS_Shape& S, const Standard_Integer Upper)
+inline Standard_Integer TopTools_OrientedShapeMapHasher::HashCode (const TopoDS_Shape& theShape,
+ const Standard_Integer theUpperBound)
{
- return S.HashCode(Upper);
+ return theShape.HashCode (theUpperBound);
}
//=======================================================================
DEFINE_STANDARD_ALLOC
-
- //! Returns a HasCode value for the Key <K> in the
- //! range 0..Upper.
- static Standard_Integer HashCode (const TopoDS_Shape& S, const Standard_Integer Upper);
-
+ //! Computes a hash code for the given shape, in the range [1, theUpperBound]
+ //! @param theShape the shape which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const TopoDS_Shape& theShape, Standard_Integer theUpperBound);
+
//! Returns True when the two keys are the same. Two
//! same keys must have the same hashcode, the
//! contrary is not necessary.
#include <TopoDS_Shape.hxx>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-inline Standard_Integer TopTools_ShapeMapHasher::HashCode
- (const TopoDS_Shape& S, const Standard_Integer Upper)
+inline Standard_Integer TopTools_ShapeMapHasher::HashCode (const TopoDS_Shape& theShape,
+ const Standard_Integer theUpperBound)
{
- return S.HashCode(Upper);
+ return theShape.HashCode (theUpperBound);
}
//=======================================================================
#include <TopoDS_TShape.hxx>
//=======================================================================
-//function : HashCode
-//purpose :
+// function : HashCode
+// purpose :
//=======================================================================
-Standard_Integer TopoDS_Shape::HashCode(const Standard_Integer Upper) const
+Standard_Integer TopoDS_Shape::HashCode (const Standard_Integer theUpperBound) const
{
- //PKV
- const Standard_Integer aI = (Standard_Integer) ptrdiff_t(myTShape.get());
- const Standard_Integer aHS = ::HashCode(aI,Upper);
- const Standard_Integer aHL = myLocation.HashCode(Upper);
- return (aHS^aHL)%Upper;
-}
+ // PKV
+ const Standard_Integer aHS = ::HashCode (myTShape.get(), theUpperBound);
+ const Standard_Integer aHL = myLocation.HashCode (theUpperBound);
+ return ::HashCode (aHS ^ aHL, theUpperBound);
+}
Standard_Boolean IsNotEqual (const TopoDS_Shape& theOther) const { return !IsEqual (theOther); }
Standard_Boolean operator != (const TopoDS_Shape& theOther) const { return IsNotEqual (theOther); }
- //! Returns a hashed value denoting <me>. This value
- //! is in the range 1..<Upper>. It is computed from
- //! the TShape and the Location. The Orientation is
- //! not used.
- Standard_EXPORT Standard_Integer HashCode (const Standard_Integer Upper) const;
+ //! Returns a hashed value denoting <me>. This value is in the range [1, theUpperBound]. It is computed from the
+ //! TShape and the Location. The Orientation is not used.
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT Standard_Integer HashCode (Standard_Integer theUpperBound) const;
//! Replace <me> by a new Shape with the same
//! Orientation and Location and a new TShape with the
};
-inline Standard_Integer HashCode(const TopoDS_Shape& me,const Standard_Integer Upper) {
- return me.HashCode(Upper);
+//! Computes a hash code for the given shape, in the range [1, theUpperBound]
+//! @param theShape the shape which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+inline Standard_Integer HashCode (const TopoDS_Shape& theShape, const Standard_Integer theUpperBound)
+{
+ return theShape.HashCode (theUpperBound);
}
#endif // _TopoDS_Shape_HeaderFile
#include <Transfer_Finder.hxx>
#include <Transfer_FindHasher.hxx>
-Standard_Integer Transfer_FindHasher::HashCode
- (const Handle(Transfer_Finder)& K, const Standard_Integer Upper)
+
+//============================================================================
+// function : HashCode
+// purpose :
+//============================================================================
+Standard_Integer Transfer_FindHasher::HashCode (const Handle (Transfer_Finder) & theFinder,
+ const Standard_Integer theUpperBound)
{
- return ((K->GetHashCode() - 1) % Upper) + 1;
+ return ::HashCode (theFinder->GetHashCode() - 1, theUpperBound);
}
Standard_Boolean Transfer_FindHasher::IsEqual
DEFINE_STANDARD_ALLOC
- //! Returns a HashCode in the range <0,Upper> for a Finder :
- //! asks the Finder its HashCode then transforms it to be in the
- //! required range
- Standard_EXPORT static Standard_Integer HashCode (const Handle(Transfer_Finder)& K, const Standard_Integer Upper);
-
+ //! Returns hash code for the given finder, in the range [1, theUpperBound].
+ //! Asks the finder its hash code, then transforms it to be in the required range
+ //! @param theFinder the finder which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ Standard_EXPORT static Standard_Integer HashCode (const Handle (Transfer_Finder) & theFinder,
+ Standard_Integer theUpperBound);
+
//! Returns True if two keys are the same.
//! The test does not work on the Finders themselves but by
//! calling their methods Equates
}
//=======================================================================
-//function : HashCode
-//purpose : Global method
+// function : HashCode
+// purpose : Global method
//=======================================================================
-
-Standard_Integer HashCode(const Handle(VrmlData_Node)& theNode,
- const Standard_Integer theUpper)
+Standard_Integer HashCode (const Handle (VrmlData_Node) & theNode, const Standard_Integer theUpperBound)
{
- return (theNode->Name() == 0L ? 0
- : HashCode((Standard_CString)theNode->Name(), theUpper));
+ return (theNode->Name () == NULL ? 1 : HashCode (theNode->Name (), theUpperBound));
}
//=======================================================================
// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE (VrmlData_Node, Standard_Transient)
-Standard_EXPORT Standard_Integer HashCode(const Handle(VrmlData_Node)& theNode,
- const Standard_Integer theUpper);
+//! Computes a hash code for the given VRML node, in the range [1, theUpperBound]
+//! @param theNode the VRML node which hash code is to be computed
+//! @param theUpperBound the upper bound of the range a computing hash code must be within
+//! @return a computed hash code, in the range [1, theUpperBound]
+Standard_EXPORT Standard_Integer HashCode (const Handle (VrmlData_Node) & theNode, Standard_Integer theUpperBound);
+
Standard_EXPORT Standard_Boolean IsEqual (const Handle(VrmlData_Node)& theOne,
const Handle(VrmlData_Node)& theTwo);
struct Hasher
{
- static int HashCode(const XCAFDoc_AssemblyItemId& theItem,
- const int upper)
+
+ //! Computes a hash code for the given value of the XCAFDoc_AssemblyItemId, in range [1, theUpperBound]
+ //! @param theAssemblyItemId the value of the XCAFDoc_AssemblyItemId type which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in range [1, theUpperBound]
+ static Standard_Integer HashCode (const XCAFDoc_AssemblyItemId& theAssemblyItemId,
+ const Standard_Integer theUpperBound)
{
- return ::HashCode(theItem.ToString(), upper);
+ return ::HashCode (theAssemblyItemId.ToString(), theUpperBound);
}
static int IsEqual(const XCAFDoc_AssemblyItemId& theItem1,
return IsEqual (theOther);
}
- //! Returns a HasCode value.
- static Standard_Integer HashCode (const XCAFPrs_Style& theStyle,
- const Standard_Integer theUpper)
+ //! Computes a hash code for the given set of styling settings, in the range [1, theUpperBound]
+ //! @param theStyle the set of styling settings which hash code is to be computed
+ //! @param theUpperBound the upper bound of the range a computing hash code must be within
+ //! @return a computed hash code, in the range [1, theUpperBound]
+ static Standard_Integer HashCode (const XCAFPrs_Style& theStyle, const Standard_Integer theUpperBound)
{
if (!theStyle.myIsVisible)
{
return 1;
}
- int aHashCode = 0;
+ Standard_Integer aHashCode = 0;
if (theStyle.myHasColorSurf)
{
- aHashCode = aHashCode ^ Quantity_ColorRGBAHasher::HashCode (theStyle.myColorSurf, theUpper);
+ aHashCode = aHashCode ^ Quantity_ColorRGBAHasher::HashCode (theStyle.myColorSurf, theUpperBound);
}
if (theStyle.myHasColorCurv)
{
- aHashCode = aHashCode ^ Quantity_ColorHasher::HashCode (theStyle.myColorCurv, theUpper);
+ aHashCode = aHashCode ^ Quantity_ColorHasher::HashCode (theStyle.myColorCurv, theUpperBound);
}
- return ((aHashCode & 0x7fffffff) % theUpper) + 1;
+ return ::HashCode (aHashCode, theUpperBound);
}
//! Returns True when the two keys are the same.