mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: replace DictionaryBase toc with sortedToc version (#1467)
- cannot rely on the entries having a keyword method STYLE: apply consistent hash table sizing for debug objects
This commit is contained in:
committed by
Andrew Heather
parent
9f11d892f5
commit
5213a4aa9d
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -27,7 +27,7 @@ Class
|
|||||||
Foam::Dictionary
|
Foam::Dictionary
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Gerneral purpose template dictionary class which manages the storage
|
General purpose template dictionary class that manages the storage
|
||||||
associated with it.
|
associated with it.
|
||||||
|
|
||||||
It is derived from DictionaryBase instantiated on a memory managed form
|
It is derived from DictionaryBase instantiated on a memory managed form
|
||||||
@ -58,22 +58,21 @@ class Dictionary
|
|||||||
:
|
:
|
||||||
public DictionaryBase<IDLList<T>, T>
|
public DictionaryBase<IDLList<T>, T>
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct given initial table size
|
//- Construct with given or default (128) table capacity
|
||||||
Dictionary(const label size = 128);
|
explicit Dictionary(const label size = 128);
|
||||||
|
|
||||||
//- Copy construct
|
//- Copy construct
|
||||||
Dictionary(const Dictionary&);
|
Dictionary(const Dictionary& dict);
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Remove an entry specified by keyword and delete the pointer.
|
//- Remove an entry specified by keyword and delete the pointer.
|
||||||
// Returns true if the keyword was found
|
// \return true if the keyword was found
|
||||||
bool erase(const word& keyword);
|
bool erase(const word& keyword);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -158,15 +158,10 @@ T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword)
|
|||||||
template<class IDLListType, class T>
|
template<class IDLListType, class T>
|
||||||
Foam::wordList Foam::DictionaryBase<IDLListType, T>::toc() const
|
Foam::wordList Foam::DictionaryBase<IDLListType, T>::toc() const
|
||||||
{
|
{
|
||||||
wordList keywords(this->size());
|
// Cannot rely on the items themselves having a keyword() method
|
||||||
|
// so simply return the toc() from the hashed entries
|
||||||
label i = 0;
|
// Make it sorted, since anything else would have no meaning.
|
||||||
for (auto iter = this->cbegin(); iter != this->cend(); ++iter)
|
return hashedTs_.sortedToc();
|
||||||
{
|
|
||||||
keywords[i++] = iter().keyword();
|
|
||||||
}
|
|
||||||
|
|
||||||
return keywords;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -94,8 +94,8 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct given initial table size
|
//- Construct with given or default (128) table capacity
|
||||||
DictionaryBase(const label size = 128);
|
explicit DictionaryBase(const label size = 128);
|
||||||
|
|
||||||
//- Copy construct
|
//- Copy construct
|
||||||
DictionaryBase(const DictionaryBase& dict);
|
DictionaryBase(const DictionaryBase& dict);
|
||||||
@ -108,7 +108,7 @@ public:
|
|||||||
DictionaryBase(Istream& is);
|
DictionaryBase(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
// Search and lookup
|
// Search and lookup
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
//- Find and return entry
|
//- Find and return entry
|
||||||
T* lookup(const word& keyword);
|
T* lookup(const word& keyword);
|
||||||
|
|
||||||
//- Return the table of contents
|
//- Return the table of contents (as a sorted list)
|
||||||
wordList toc() const;
|
wordList toc() const;
|
||||||
|
|
||||||
//- Return the table of contents as a sorted list
|
//- Return the table of contents as a sorted list
|
||||||
@ -141,25 +141,26 @@ public:
|
|||||||
// Editing
|
// Editing
|
||||||
|
|
||||||
//- Add at head of dictionary
|
//- Add at head of dictionary
|
||||||
void insert(const word&, T*);
|
void insert(const word& keyword, T*);
|
||||||
|
|
||||||
//- Add at tail of dictionary
|
//- Add at tail of dictionary
|
||||||
void append(const word&, T*);
|
void append(const word& keyword, T*);
|
||||||
|
|
||||||
//- Remove and return entry specified by keyword.
|
//- Remove and return entry specified by keyword.
|
||||||
// Return nullptr if the keyword was not found.
|
// Return nullptr if the keyword was not found.
|
||||||
T* remove(const word&);
|
T* remove(const word& keyword);
|
||||||
|
|
||||||
//- Clear the dictionary
|
//- Clear the dictionary
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
//- Transfer the contents of the argument into this DictionaryBase
|
//- Transfer the contents of the argument into this DictionaryBase
|
||||||
// and annul the argument.
|
// and annul the argument.
|
||||||
void transfer(DictionaryBase<IDLListType, T>&);
|
void transfer(DictionaryBase<IDLListType, T>& dict);
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member Operators
|
||||||
|
|
||||||
|
//- Copy assigment
|
||||||
void operator=(const DictionaryBase&);
|
void operator=(const DictionaryBase&);
|
||||||
|
|
||||||
//- Find and return entry
|
//- Find and return entry
|
||||||
@ -175,7 +176,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Ostream operator
|
// Ostream Operator
|
||||||
|
|
||||||
friend Ostream& operator<< <IDLListType, T>
|
friend Ostream& operator<< <IDLListType, T>
|
||||||
(
|
(
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -23,9 +23,6 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Description
|
|
||||||
Reads the data description and data portions of a DictionaryBase File.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "DictionaryBase.H"
|
#include "DictionaryBase.H"
|
||||||
@ -39,12 +36,7 @@ Foam::Ostream& Foam::operator<<
|
|||||||
Ostream& os,
|
Ostream& os,
|
||||||
const DictionaryBase<IDLListType, T>& dict)
|
const DictionaryBase<IDLListType, T>& dict)
|
||||||
{
|
{
|
||||||
for
|
for (auto iter = dict.begin(); iter != dict.end(); ++iter)
|
||||||
(
|
|
||||||
typename IDLListType::const_iterator iter = dict.begin();
|
|
||||||
iter != dict.end();
|
|
||||||
++iter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
os << *iter;
|
os << *iter;
|
||||||
|
|
||||||
@ -56,7 +48,7 @@ Foam::Ostream& Foam::operator<<
|
|||||||
<< "Can't write entry for DictionaryBase"
|
<< "Can't write entry for DictionaryBase"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
return os;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2018 OpenFOAM Foundation
|
| Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
@ -339,7 +339,7 @@ Foam::simpleObjectRegistry& Foam::debug::debugObjects()
|
|||||||
{
|
{
|
||||||
if (!debugObjectsPtr_)
|
if (!debugObjectsPtr_)
|
||||||
{
|
{
|
||||||
debugObjectsPtr_ = new simpleObjectRegistry(1000);
|
debugObjectsPtr_ = new simpleObjectRegistry(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *debugObjectsPtr_;
|
return *debugObjectsPtr_;
|
||||||
@ -350,7 +350,7 @@ Foam::simpleObjectRegistry& Foam::debug::infoObjects()
|
|||||||
{
|
{
|
||||||
if (!infoObjectsPtr_)
|
if (!infoObjectsPtr_)
|
||||||
{
|
{
|
||||||
infoObjectsPtr_ = new simpleObjectRegistry(100);
|
infoObjectsPtr_ = new simpleObjectRegistry(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *infoObjectsPtr_;
|
return *infoObjectsPtr_;
|
||||||
@ -361,7 +361,7 @@ Foam::simpleObjectRegistry& Foam::debug::optimisationObjects()
|
|||||||
{
|
{
|
||||||
if (!optimisationObjectsPtr_)
|
if (!optimisationObjectsPtr_)
|
||||||
{
|
{
|
||||||
optimisationObjectsPtr_ = new simpleObjectRegistry(100);
|
optimisationObjectsPtr_ = new simpleObjectRegistry(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *optimisationObjectsPtr_;
|
return *optimisationObjectsPtr_;
|
||||||
@ -372,7 +372,7 @@ Foam::simpleObjectRegistry& Foam::debug::dimensionSetObjects()
|
|||||||
{
|
{
|
||||||
if (!dimensionSetObjectsPtr_)
|
if (!dimensionSetObjectsPtr_)
|
||||||
{
|
{
|
||||||
dimensionSetObjectsPtr_ = new simpleObjectRegistry(100);
|
dimensionSetObjectsPtr_ = new simpleObjectRegistry(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *dimensionSetObjectsPtr_;
|
return *dimensionSetObjectsPtr_;
|
||||||
@ -383,7 +383,7 @@ Foam::simpleObjectRegistry& Foam::debug::dimensionedConstantObjects()
|
|||||||
{
|
{
|
||||||
if (!dimensionedConstantObjectsPtr_)
|
if (!dimensionedConstantObjectsPtr_)
|
||||||
{
|
{
|
||||||
dimensionedConstantObjectsPtr_ = new simpleObjectRegistry(100);
|
dimensionedConstantObjectsPtr_ = new simpleObjectRegistry(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *dimensionedConstantObjectsPtr_;
|
return *dimensionedConstantObjectsPtr_;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2012-2016 OpenFOAM Foundation
|
| Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||||
@ -74,10 +74,10 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct given initial table size
|
//- Construct with given or default (128) table capacity
|
||||||
simpleObjectRegistry(const label nIoObjects = 128)
|
explicit simpleObjectRegistry(const label size = 128)
|
||||||
:
|
:
|
||||||
Dictionary<simpleObjectRegistryEntry>(nIoObjects)
|
Dictionary<simpleObjectRegistryEntry>(size)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user