Commit 573a313f authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: deprecate hashedWordList contains() method

- identical to found(), which should be used for more consistency.
  The contains() is a remnant from when hashedWordList was generalized
  from a speciesTable (OCT 2010)
parent 86e19330
......@@ -89,7 +89,7 @@ Foam::interfaceCompositionModels::Henry<Thermo, OtherThermo>::Yf
const volScalarField& Tf
) const
{
if (this->speciesNames_.contains(speciesName))
if (this->speciesNames_.found(speciesName))
{
const label index = this->speciesNames_[speciesName];
......
......@@ -121,7 +121,7 @@ Foam::interfaceCompositionModels::Raoult<Thermo, OtherThermo>::Yf
const volScalarField& Tf
) const
{
if (this->speciesNames_.contains(speciesName))
if (this->speciesNames_.found(speciesName))
{
return
this->otherThermo_.composition().Y(speciesName)
......@@ -144,7 +144,7 @@ Foam::interfaceCompositionModels::Raoult<Thermo, OtherThermo>::YfPrime
const volScalarField& Tf
) const
{
if (this->speciesNames_.contains(speciesName))
if (this->speciesNames_.found(speciesName))
{
return
this->otherThermo_.composition().Y(speciesName)
......
......@@ -63,17 +63,9 @@ const Foam::hashedWordList& Foam::interfaceCompositionModel::species() const
}
bool Foam::interfaceCompositionModel::transports
(
word& speciesName
) const
bool Foam::interfaceCompositionModel::transports(word& speciesName) const
{
if (this->speciesNames_.contains(speciesName))
{
return true;
}
return false;
return this->speciesNames_.found(speciesName);
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -47,7 +47,7 @@ namespace Foam
// Forward declarations
class hashedWordList;
inline Istream& operator>>(Istream& is, hashedWordList& lst);
inline Istream& operator>>(Istream& is, hashedWordList& list);
/*---------------------------------------------------------------------------*\
......@@ -71,22 +71,22 @@ public:
inline hashedWordList() = default;
//- Copy construct.
inline hashedWordList(const hashedWordList& lst);
inline hashedWordList(const hashedWordList& list);
//- Move construct.
inline hashedWordList(hashedWordList&& lst);
inline hashedWordList(hashedWordList&& list);
//- Copy construct from list of words
inline explicit hashedWordList(const wordUList& lst);
inline explicit hashedWordList(const wordUList& list);
//- Copy construct from list of words, eliminating duplicates
inline hashedWordList(const wordUList& lst, bool unique);
inline hashedWordList(const wordUList& list, bool unique);
//- Move construct from list of words, optionally eliminating duplicates
inline hashedWordList(wordList&& lst, bool unique=false);
inline hashedWordList(wordList&& list, bool unique=false);
//- Construct from an initializer list
inline hashedWordList(std::initializer_list<word> lst);
inline hashedWordList(std::initializer_list<word> list);
//- Construct from the word keys of any HashTable, sorting immediately.
// This also handles a wordHashSet, which is derived from a HashTable.
......@@ -102,7 +102,7 @@ public:
hashedWordList(const label len, const char** array, bool unique=false);
//- Construct from a nullptr-terminated list of words,
// optionally eliminating duplicates
//- optionally eliminating duplicates
hashedWordList(const char** array, bool unique=false);
//- Construct from Istream
......@@ -115,28 +115,25 @@ public:
inline void clear();
//- Append an element at the end of the list,
// optionally avoid append if it would be a duplicate entry
//- optionally avoid append if it would be a duplicate entry
inline void append(const word& name, bool unique=false);
//- Does the list contain the specified name
//- Search hashed values for the specified name
inline bool found(const word& name) const;
//- Does the list contain the specified name
inline bool contains(const word& name) const;
//- Return the hash of words/indices for inspection
inline const HashTable<label>& lookup() const;
//- Swap contents
inline void swap(hashedWordList& lst);
inline void swap(hashedWordList& list);
//- Transfer contents of the argument into this list
//- and annul the argument list, optionally eliminating duplicates
inline void transfer(hashedWordList& lst);
inline void transfer(hashedWordList& list);
//- Transfer the contents of the argument List into this list
//- and annul the argument list, optionally eliminating duplicates
inline void transfer(wordList& lst, bool unique=false);
inline void transfer(wordList& list, bool unique=false);
//- Rebuild the lookup hash indices
void rehash() const;
......@@ -166,25 +163,36 @@ public:
inline bool operator()(const word& name) const;
// Assignment
// Assignment
//- Copy assignment. Rehashes the indices.
inline void operator=(const hashedWordList& lst);
inline void operator=(const hashedWordList& list);
//- Copy assignment from list of words. Rehashes the indices.
inline void operator=(const wordUList& lst);
inline void operator=(const wordUList& list);
//- Copy assignment from initializer list. Rehashes the indices.
inline void operator=(std::initializer_list<word> lst);
inline void operator=(std::initializer_list<word> list);
//- Move assignment operator.
inline void operator=(hashedWordList&& lst);
inline void operator=(hashedWordList&& list);
//- Move assignment from list of words. Rehashes the indices.
inline void operator=(wordList&& lst);
inline void operator=(wordList&& list);
//- Read from an input stream. Rehashes the indices.
inline friend Istream& operator>>(Istream& is, hashedWordList& lst);
inline friend Istream& operator>>(Istream& is, hashedWordList& list);
// Housekeeping
//- Deprecated(2019-01) Is the specified name found in the list?
// \deprecated(2019-01) - use found() method
inline bool contains(const word& name) const
FOAM_DEPRECATED_FOR(2019-01, "found() method")
{
return this-found(name);
}
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,44 +25,44 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::hashedWordList::hashedWordList(const hashedWordList& lst)
inline Foam::hashedWordList::hashedWordList(const hashedWordList& list)
:
hashedWordList(static_cast<const wordUList&>(lst), false)
hashedWordList(static_cast<const wordUList&>(list), false)
{}
inline Foam::hashedWordList::hashedWordList(hashedWordList&& lst)
inline Foam::hashedWordList::hashedWordList(hashedWordList&& list)
:
wordList(std::move(static_cast<wordList&>(lst))),
lookup_(std::move(lst.lookup_))
wordList(std::move(static_cast<wordList&>(list))),
lookup_(std::move(list.lookup_))
{}
inline Foam::hashedWordList::hashedWordList(const wordUList& lst)
inline Foam::hashedWordList::hashedWordList(const wordUList& list)
:
hashedWordList(lst, false)
hashedWordList(list, false)
{}
inline Foam::hashedWordList::hashedWordList(const wordUList& lst, bool unique)
inline Foam::hashedWordList::hashedWordList(const wordUList& list, bool unique)
:
wordList(lst)
wordList(list)
{
rehash(unique);
}
inline Foam::hashedWordList::hashedWordList(wordList&& lst, bool unique)
inline Foam::hashedWordList::hashedWordList(wordList&& list, bool unique)
:
wordList(std::move(lst))
wordList(std::move(list))
{
rehash(unique);
}
inline Foam::hashedWordList::hashedWordList(std::initializer_list<word> lst)
inline Foam::hashedWordList::hashedWordList(std::initializer_list<word> list)
:
wordList(lst)
wordList(list)
{
rehash();
}
......@@ -128,38 +128,37 @@ Foam::hashedWordList::lookup() const
}
inline bool Foam::hashedWordList::found(const word& name) const
{
return lookup().found(name);
}
// TBD (2019-01-07) - overload find() for consistency?
//
// inline Foam::label Foam::hashedWordList::find(const word& name) const
// {
// return lookup().lookup(name, -1); // -1 = not found or not hashed
// }
inline bool Foam::hashedWordList::contains(const word& name) const
inline bool Foam::hashedWordList::found(const word& name) const
{
return lookup().found(name);
}
inline void Foam::hashedWordList::swap(hashedWordList& lst)
inline void Foam::hashedWordList::swap(hashedWordList& list)
{
wordList::swap(static_cast<wordList&>(lst));
lookup_.swap(lst.lookup_);
wordList::swap(static_cast<wordList&>(list));
lookup_.swap(list.lookup_);
}
inline void Foam::hashedWordList::transfer
(
hashedWordList& lst
)
inline void Foam::hashedWordList::transfer(hashedWordList& list)
{
wordList::transfer(static_cast<wordList&>(lst));
lookup_.transfer(lst.lookup_);
wordList::transfer(static_cast<wordList&>(list));
lookup_.transfer(list.lookup_);
}
inline void Foam::hashedWordList::transfer(wordList& lst, bool unique)
inline void Foam::hashedWordList::transfer(wordList& list, bool unique)
{
wordList::transfer(lst);
wordList::transfer(list);
rehash(unique);
}
......@@ -207,47 +206,47 @@ inline bool Foam::hashedWordList::operator()(const word& name) const
}
inline void Foam::hashedWordList::operator=(const hashedWordList& lst)
inline void Foam::hashedWordList::operator=(const hashedWordList& list)
{
wordList::operator=(lst);
wordList::operator=(list);
rehash();
}
inline void Foam::hashedWordList::operator=(const wordUList& lst)
inline void Foam::hashedWordList::operator=(const wordUList& list)
{
wordList::operator=(lst);
wordList::operator=(list);
rehash();
}
inline void Foam::hashedWordList::operator=(std::initializer_list<word> lst)
inline void Foam::hashedWordList::operator=(std::initializer_list<word> list)
{
wordList::operator=(lst);
wordList::operator=(list);
rehash();
}
inline void Foam::hashedWordList::operator=(hashedWordList&& lst)
inline void Foam::hashedWordList::operator=(hashedWordList&& list)
{
wordList::transfer(static_cast<wordList&>(lst));
lookup_ = std::move(lst.lookup_);
wordList::transfer(static_cast<wordList&>(list));
lookup_ = std::move(list.lookup_);
}
inline void Foam::hashedWordList::operator=(wordList&& lst)
inline void Foam::hashedWordList::operator=(wordList&& list)
{
wordList::transfer(lst);
wordList::transfer(list);
rehash();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
inline Foam::Istream& Foam::operator>>(Istream& is, hashedWordList& lst)
inline Foam::Istream& Foam::operator>>(Istream& is, hashedWordList& list)
{
is >> static_cast<wordList&>(lst);
lst.rehash();
is >> static_cast<wordList&>(list);
list.rehash();
return is;
}
......
......@@ -35,7 +35,7 @@ inline bool Foam::basicMultiComponentMixture::contains
const word& specieName
) const
{
return species_.contains(specieName);
return species_.found(specieName);
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -219,14 +219,8 @@ Foam::Reaction<ReactionThermo>::specieCoeffs::specieCoeffs
specieName.resize(i);
}
if (species.contains(specieName))
{
index = species[specieName];
}
else
{
index = -1;
}
// -1 if not found
index = species[specieName];
}
else
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment