File indexing completed on 2025-01-18 10:03:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _BOPDS_Pair_HeaderFile
0016 #define _BOPDS_Pair_HeaderFile
0017
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 #include <Standard_HashUtils.hxx>
0021
0022
0023
0024 class BOPDS_Pair {
0025 public:
0026
0027 DEFINE_STANDARD_ALLOC
0028
0029 BOPDS_Pair() : myIndex1(-1), myIndex2(-1) {}
0030
0031 BOPDS_Pair(const Standard_Integer theIndex1,
0032 const Standard_Integer theIndex2) : myIndex1(theIndex1), myIndex2(theIndex2) {}
0033
0034 ~BOPDS_Pair(){}
0035
0036
0037 void SetIndices(const Standard_Integer theIndex1,
0038 const Standard_Integer theIndex2)
0039 {
0040 myIndex1 = theIndex1;
0041 myIndex2 = theIndex2;
0042 }
0043
0044
0045 void Indices(Standard_Integer& theIndex1,
0046 Standard_Integer& theIndex2) const
0047 {
0048 theIndex1 = myIndex1;
0049 theIndex2 = myIndex2;
0050 }
0051
0052
0053 Standard_Boolean operator < (const BOPDS_Pair& theOther) const
0054 {
0055 return ((myIndex1 != theOther.myIndex1) ?
0056 (myIndex1 < theOther.myIndex1) : (myIndex2 < theOther.myIndex2));
0057 }
0058
0059
0060 Standard_Boolean IsEqual (const BOPDS_Pair& theOther) const
0061 {
0062 return (myIndex1 == theOther.myIndex1 && myIndex2 == theOther.myIndex2) ||
0063 (myIndex1 == theOther.myIndex2 && myIndex2 == theOther.myIndex1);
0064 }
0065
0066 bool operator==(const BOPDS_Pair& theOther) const
0067 {
0068 return IsEqual(theOther);
0069 }
0070
0071 protected:
0072 Standard_Integer myIndex1;
0073 Standard_Integer myIndex2;
0074 };
0075
0076 namespace std
0077 {
0078 template <>
0079 struct hash<BOPDS_Pair>
0080 {
0081 size_t operator()(const BOPDS_Pair& thePair) const noexcept
0082 {
0083
0084 int aCombination[2];
0085 thePair.Indices(aCombination[0], aCombination[1]);
0086 if (aCombination[0] > aCombination[1])
0087 {
0088 std::swap(aCombination[0], aCombination[1]);
0089 }
0090 return opencascade::hashBytes(aCombination, sizeof(aCombination));
0091 }
0092 };
0093 }
0094
0095 #endif