mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
STYLE: simplify hashing to use struct instead of class
- more consistent with STL practices for function classes. - string::hash function class now operates on std::string rather than Foam::string since we have now avoided inadvertent use of string conversion from int in more places.
This commit is contained in:
@ -27,14 +27,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::phasePairKey::hash::hash()
|
||||
{}
|
||||
|
||||
|
||||
Foam::phasePairKey::phasePairKey()
|
||||
{}
|
||||
|
||||
|
||||
Foam::phasePairKey::phasePairKey
|
||||
(
|
||||
const word& name1,
|
||||
@ -47,12 +39,6 @@ Foam::phasePairKey::phasePairKey
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::phasePairKey::~phasePairKey()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::phasePairKey::hash::operator()
|
||||
@ -86,13 +72,13 @@ bool Foam::operator==
|
||||
const phasePairKey& b
|
||||
)
|
||||
{
|
||||
const label c = Pair<word>::compare(a,b);
|
||||
const label cmp = Pair<word>::compare(a,b);
|
||||
|
||||
return
|
||||
(a.ordered_ == b.ordered_)
|
||||
&& (
|
||||
(a.ordered_ && (c == 1))
|
||||
|| (!a.ordered_ && (c != 0))
|
||||
(a.ordered_ && (cmp == 1))
|
||||
|| (!a.ordered_ && (cmp != 0))
|
||||
);
|
||||
}
|
||||
|
||||
@ -119,7 +105,7 @@ Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key)
|
||||
{
|
||||
key.ordered_ = false;
|
||||
}
|
||||
else if(temp[1] == "in")
|
||||
else if (temp[1] == "in")
|
||||
{
|
||||
key.ordered_ = true;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
// Forward declarations
|
||||
|
||||
class phasePairKey;
|
||||
|
||||
@ -59,48 +59,36 @@ class phasePairKey
|
||||
:
|
||||
public Pair<word>
|
||||
{
|
||||
public:
|
||||
|
||||
class hash
|
||||
:
|
||||
public Hash<phasePairKey>
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
// Construct null
|
||||
hash();
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
// Generate a hash from a phase pair key
|
||||
label operator()(const phasePairKey& key) const;
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Flag to indicate whether ordering is important
|
||||
bool ordered_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
struct hash
|
||||
{
|
||||
// Generate a hash from a phase pair key
|
||||
label operator()(const phasePairKey& key) const;
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
phasePairKey();
|
||||
phasePairKey() {} // = default
|
||||
|
||||
//- Construct from names and the ordering flag
|
||||
phasePairKey(const word& name1, const word& name2, const bool ordered);
|
||||
phasePairKey
|
||||
(
|
||||
const word& name1,
|
||||
const word& name2,
|
||||
const bool ordered
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
virtual ~phasePairKey();
|
||||
virtual ~phasePairKey() = default;
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
Reference in New Issue
Block a user