Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:16

0001 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _MeshVS_SymmetricPairHasher_HeaderFile
0015 #define _MeshVS_SymmetricPairHasher_HeaderFile
0016 
0017 #include <Standard_Type.hxx>
0018 #include <Standard_HashUtils.hxx>
0019 
0020 typedef std::pair<Standard_Integer, Standard_Integer> MeshVS_NodePair;
0021 
0022 //! Provides symmetric hash methods pair of integers.
0023 struct MeshVS_SymmetricPairHasher
0024 {
0025   //! Computes a hash code for the node pair
0026   //! @param theNodePair the node pair which hash code is to be computed
0027   //! @return a computed hash code
0028   size_t operator()(const MeshVS_NodePair& theNodePair) const noexcept
0029   {
0030     // Combine two int values into a single hash value.
0031     int aCombination[2]{ theNodePair.first, theNodePair.second };
0032     if (aCombination[0] > aCombination[1])
0033     {
0034       std::swap(aCombination[0], aCombination[1]);
0035     }
0036     return opencascade::hashBytes(aCombination, sizeof(aCombination));
0037   }
0038 
0039   bool operator()(const MeshVS_NodePair& thePair1, const MeshVS_NodePair& thePair2) const noexcept
0040   {
0041     return (thePair1.first == thePair2.first && thePair1.second == thePair2.second)
0042       || (thePair1.first == thePair2.second && thePair1.second == thePair2.first);
0043   }
0044 };
0045 
0046 #endif // _MeshVS_SymmetricPairHasher_HeaderFile