diff --git a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H index fc65924267..08b5246b69 100644 --- a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -27,7 +27,7 @@ Class Foam::Dictionary Description - Gerneral purpose template dictionary class which manages the storage + General purpose template dictionary class that manages the storage associated with it. It is derived from DictionaryBase instantiated on a memory managed form @@ -58,22 +58,21 @@ class Dictionary : public DictionaryBase, T> { - public: // Constructors - //- Construct given initial table size - Dictionary(const label size = 128); + //- Construct with given or default (128) table capacity + explicit Dictionary(const label size = 128); //- Copy construct - Dictionary(const Dictionary&); + Dictionary(const Dictionary& dict); - // Member functions + // Member Functions //- 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); }; diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C index 14a75287c9..bd0ff195ae 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C @@ -158,15 +158,10 @@ T* Foam::DictionaryBase::lookup(const word& keyword) template Foam::wordList Foam::DictionaryBase::toc() const { - wordList keywords(this->size()); - - label i = 0; - for (auto iter = this->cbegin(); iter != this->cend(); ++iter) - { - keywords[i++] = iter().keyword(); - } - - return keywords; + // Cannot rely on the items themselves having a keyword() method + // so simply return the toc() from the hashed entries + // Make it sorted, since anything else would have no meaning. + return hashedTs_.sortedToc(); } diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H index 0dd7f77c13..407cfde52d 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H @@ -94,8 +94,8 @@ public: // Constructors - //- Construct given initial table size - DictionaryBase(const label size = 128); + //- Construct with given or default (128) table capacity + explicit DictionaryBase(const label size = 128); //- Copy construct DictionaryBase(const DictionaryBase& dict); @@ -108,7 +108,7 @@ public: DictionaryBase(Istream& is); - // Member functions + // Member Functions // Search and lookup @@ -127,7 +127,7 @@ public: //- Find and return entry T* lookup(const word& keyword); - //- Return the table of contents + //- Return the table of contents (as a sorted list) wordList toc() const; //- Return the table of contents as a sorted list @@ -141,25 +141,26 @@ public: // Editing //- Add at head of dictionary - void insert(const word&, T*); + void insert(const word& keyword, T*); //- Add at tail of dictionary - void append(const word&, T*); + void append(const word& keyword, T*); //- Remove and return entry specified by keyword. // Return nullptr if the keyword was not found. - T* remove(const word&); + T* remove(const word& keyword); //- Clear the dictionary void clear(); //- Transfer the contents of the argument into this DictionaryBase // and annul the argument. - void transfer(DictionaryBase&); + void transfer(DictionaryBase& dict); - // Member operators + // Member Operators + //- Copy assigment void operator=(const DictionaryBase&); //- Find and return entry @@ -175,7 +176,7 @@ public: } - // Ostream operator + // Ostream Operator friend Ostream& operator<< ( diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C index a24ebbfdbd..18a841f62c 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -23,9 +23,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - Reads the data description and data portions of a DictionaryBase File. - \*---------------------------------------------------------------------------*/ #include "DictionaryBase.H" @@ -39,12 +36,7 @@ Foam::Ostream& Foam::operator<< Ostream& os, const DictionaryBase& dict) { - for - ( - typename IDLListType::const_iterator iter = dict.begin(); - iter != dict.end(); - ++iter - ) + for (auto iter = dict.begin(); iter != dict.end(); ++iter) { os << *iter; @@ -56,7 +48,7 @@ Foam::Ostream& Foam::operator<< << "Can't write entry for DictionaryBase" << endl; - return os; + break; } } diff --git a/src/OpenFOAM/global/debug/debug.C b/src/OpenFOAM/global/debug/debug.C index bdbc0ce8c4..c37c503844 100644 --- a/src/OpenFOAM/global/debug/debug.C +++ b/src/OpenFOAM/global/debug/debug.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2018 OpenFOAM Foundation @@ -339,7 +339,7 @@ Foam::simpleObjectRegistry& Foam::debug::debugObjects() { if (!debugObjectsPtr_) { - debugObjectsPtr_ = new simpleObjectRegistry(1000); + debugObjectsPtr_ = new simpleObjectRegistry(128); } return *debugObjectsPtr_; @@ -350,7 +350,7 @@ Foam::simpleObjectRegistry& Foam::debug::infoObjects() { if (!infoObjectsPtr_) { - infoObjectsPtr_ = new simpleObjectRegistry(100); + infoObjectsPtr_ = new simpleObjectRegistry(128); } return *infoObjectsPtr_; @@ -361,7 +361,7 @@ Foam::simpleObjectRegistry& Foam::debug::optimisationObjects() { if (!optimisationObjectsPtr_) { - optimisationObjectsPtr_ = new simpleObjectRegistry(100); + optimisationObjectsPtr_ = new simpleObjectRegistry(128); } return *optimisationObjectsPtr_; @@ -372,7 +372,7 @@ Foam::simpleObjectRegistry& Foam::debug::dimensionSetObjects() { if (!dimensionSetObjectsPtr_) { - dimensionSetObjectsPtr_ = new simpleObjectRegistry(100); + dimensionSetObjectsPtr_ = new simpleObjectRegistry(128); } return *dimensionSetObjectsPtr_; @@ -383,7 +383,7 @@ Foam::simpleObjectRegistry& Foam::debug::dimensionedConstantObjects() { if (!dimensionedConstantObjectsPtr_) { - dimensionedConstantObjectsPtr_ = new simpleObjectRegistry(100); + dimensionedConstantObjectsPtr_ = new simpleObjectRegistry(128); } return *dimensionedConstantObjectsPtr_; diff --git a/src/OpenFOAM/global/debug/simpleObjectRegistry.H b/src/OpenFOAM/global/debug/simpleObjectRegistry.H index 1c8af688e6..7259f0a352 100644 --- a/src/OpenFOAM/global/debug/simpleObjectRegistry.H +++ b/src/OpenFOAM/global/debug/simpleObjectRegistry.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016 OpenFOAM Foundation @@ -74,10 +74,10 @@ public: // Constructors - //- Construct given initial table size - simpleObjectRegistry(const label nIoObjects = 128) + //- Construct with given or default (128) table capacity + explicit simpleObjectRegistry(const label size = 128) : - Dictionary(nIoObjects) + Dictionary(size) {} };