diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index f9dda76f9c..1c42c9426a 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -44,8 +44,6 @@ Note SourceFiles HashTableI.H HashTable.C - HashTableCoreI.H - HashTableCore.C HashTableIO.C \*---------------------------------------------------------------------------*/ @@ -53,13 +51,10 @@ SourceFiles #ifndef HashTable_H #define HashTable_H -#include "label.H" -#include "uLabel.H" #include "word.H" #include "Xfer.H" #include "Hash.H" -#include "className.H" -#include "nullObject.H" +#include "HashTableCore.H" #include #include @@ -84,80 +79,6 @@ template Ostream& operator<<(Ostream& os, const HashTable& tbl); -/*---------------------------------------------------------------------------*\ - Class HashTableCore Declaration -\*---------------------------------------------------------------------------*/ - -//- Bits that are independent of the HashTable template parameters. -struct HashTableCore -{ - //- Maximum allowable internal table size. Approximately labelMax/4 - static const label maxTableSize; - - //- Return a canonical (power-of-two) of the requested size. - static label canonicalSize(const label requested_size); - - //- Construct null - HashTableCore() - {} - - //- Define template name and debug - ClassName("HashTable"); - - static_assert - ( - sizeof(NullObject) >= sizeof(void*), - "NullObject is too small to reinterpret_cast as HashTable::iterator" - ); - - - //- Factory method to create a non-const iterator begin - template - inline static IteratorType iterator_begin(TableType& table); - - //- Factory method to create a const iterator begin - template - inline static IteratorType iterator_begin(const TableType& table); - - //- Factory method to create a const iterator begin - template - inline static IteratorType iterator_cbegin(const TableType& table); - - //- Factory method to create a non-const iterator end - // Simply reinterprets a NullObject as a hash-table iterator. - template - inline static const IteratorType& iterator_end(); - - //- Factory method to create a const iterator cend - // Simply reinterprets a NullObject as a hash-table iterator. - template - inline static const IteratorType& iterator_cend(); - - - //- Factory class for creating a begin/end pair for any const iterator. - template - class const_iterator_pair - { - label size_; - IteratorType iter_; - - public: - - inline const_iterator_pair(const TableType& tbl); - - inline label size() const; - inline bool empty() const; - - inline IteratorType begin() const; - inline IteratorType cbegin() const; - - inline const IteratorType& end() const; - inline const IteratorType& cend() const; - }; - -}; - - /*---------------------------------------------------------------------------*\ Class HashTable Declaration \*---------------------------------------------------------------------------*/ @@ -871,7 +792,6 @@ inline void Swap // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "HashTableCoreI.H" #include "HashTableI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C index 08805148a9..d6d7bef31d 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "HashTable.H" +#include "HashTableCore.H" #include "uLabel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H new file mode 100644 index 0000000000..46cc0c3f46 --- /dev/null +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H @@ -0,0 +1,134 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::HashTableCore + +Description + Template invariant parts of hash table implementation. + +SourceFiles + HashTableCoreI.H + HashTableCore.C + +\*---------------------------------------------------------------------------*/ + +#ifndef HashTableCore_H +#define HashTableCore_H + +#include "label.H" +#include "uLabel.H" +#include "className.H" +#include "nullObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class HashTableCore Declaration +\*---------------------------------------------------------------------------*/ + +//- Bits that are independent of HashTable template parameters. +struct HashTableCore +{ + //- Maximum allowable internal table size. Approximately labelMax/4 + static const label maxTableSize; + + //- Return a canonical (power-of-two) of the requested size. + static label canonicalSize(const label requested_size); + + //- Construct null + HashTableCore() + {} + + //- Define template name and debug + ClassName("HashTable"); + + static_assert + ( + sizeof(NullObject) >= sizeof(void*), + "NullObject is too small to reinterpret_cast as HashTable::iterator" + ); + + + //- Factory method to create a non-const iterator begin + template + inline static IteratorType iterator_begin(TableType& table); + + //- Factory method to create a const iterator begin + template + inline static IteratorType iterator_begin(const TableType& table); + + //- Factory method to create a const iterator begin + template + inline static IteratorType iterator_cbegin(const TableType& table); + + //- Factory method to create a non-const iterator end + // Simply reinterprets a NullObject as a hash-table iterator. + template + inline static const IteratorType& iterator_end(); + + //- Factory method to create a const iterator cend + // Simply reinterprets a NullObject as a hash-table iterator. + template + inline static const IteratorType& iterator_cend(); + + + //- Factory class for creating a begin/end pair for any const iterator. + template + class const_iterator_pair + { + label size_; + IteratorType iter_; + + public: + + inline const_iterator_pair(const TableType& tbl); + + inline label size() const; + inline bool empty() const; + + inline IteratorType begin() const; + inline IteratorType cbegin() const; + + inline const IteratorType& end() const; + inline const IteratorType& cend() const; + }; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "HashTableCoreI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H index 2e6b5db0ea..e93e7e4861 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H @@ -343,13 +343,6 @@ Foam::StaticHashTable::begin() } } - #ifdef FULLDEBUG - if (debug) - { - Info<< "StaticHashTable is empty\n"; - } - #endif - return StaticHashTable::endIter_; } @@ -375,13 +368,6 @@ Foam::StaticHashTable::cbegin() const } } - #ifdef FULLDEBUG - if (debug) - { - Info<< "StaticHashTable is empty\n"; - } - #endif - return StaticHashTable::endConstIter_; }