diff --git a/applications/test/HashSet/hashSetTest.C b/applications/test/HashSet/hashSetTest.C index a3527f7dd76ec3c8df4fc47d9f3dcce24ccf018c..9625b2e0dc61bc5053441729faecfbe18ea8c7d3 100644 --- a/applications/test/HashSet/hashSetTest.C +++ b/applications/test/HashSet/hashSetTest.C @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) wordHashSet setA(0); HashTable<label, word> tableA; - HashTable<empty> tableB; + HashTable<nil> tableB; Map<label> mapA; setA.insert("kjhk"); @@ -49,9 +49,9 @@ int main(int argc, char *argv[]) tableA.insert("value2", 2); tableA.insert("value3", 3); - tableB.insert("value4", empty()); - tableB.insert("value5", empty()); - tableB.insert("value6", empty()); + tableB.insert("value4", nil()); + tableB.insert("value5", nil()); + tableB.insert("value6", nil()); mapA.set(1, 1); mapA.set(2, 2); @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) Info<< wordHashSet(setA) << endl; Info<< "create from HashTable<T>: "; Info<< wordHashSet(tableA) << endl; - Info<< "create from HashTable<empty>: "; + Info<< "create from HashTable<nil>: "; Info<< wordHashSet(tableB) << endl; Info<< "create from Map<label>: "; diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C index 3e4123ae4f99c58ee5f080d8aa4dc1ee2f3289db..b741bd2b0b528893e279f229f40b6b8a5ce3a5df 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C @@ -35,7 +35,7 @@ template<class Key, class Hash> template<class T> Foam::HashSet<Key, Hash>::HashSet(const HashTable<T, Key, Hash>& ht) : - HashTable<empty, Key, Hash>(ht.size()) + HashTable<nil, Key, Hash>(ht.size()) { for ( diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H index 889ede7a7da0390fa96cab92bdef48000458ee31..0ea8f8c64607d63d027ef1cde58700ecc0c4b9de 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H @@ -46,7 +46,7 @@ Description #define HashSet_H #include "HashTable.H" -#include "empty.H" +#include "nil.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,13 +60,13 @@ namespace Foam template<class Key=word, class Hash=string::hash> class HashSet : - public HashTable<empty, Key, Hash> + public HashTable<nil, Key, Hash> { public: - typedef typename HashTable<empty, Key, Hash>::iterator iterator; - typedef typename HashTable<empty, Key, Hash>::const_iterator const_iterator; + typedef typename HashTable<nil, Key, Hash>::iterator iterator; + typedef typename HashTable<nil, Key, Hash>::const_iterator const_iterator; // Constructors @@ -74,19 +74,19 @@ public: //- Construct given initial size HashSet(label size = 100) : - HashTable<empty, Key, Hash>(size) + HashTable<nil, Key, Hash>(size) {} //- Construct from Istream HashSet(Istream& is) : - HashTable<empty, Key, Hash>(is) + HashTable<nil, Key, Hash>(is) {} //- Construct from UList of Key HashSet(const UList<Key>& lst) : - HashTable<empty, Key, Hash>(2*lst.size()) + HashTable<nil, Key, Hash>(2*lst.size()) { forAll(lst, i) { @@ -97,19 +97,19 @@ public: //- Construct as copy HashSet(const HashSet<Key, Hash>& hs) : - HashTable<empty, Key, Hash>(hs) + HashTable<nil, Key, Hash>(hs) {} //- Construct by transferring the parameter contents HashSet(const Xfer<HashSet<Key, Hash> >& hs) : - HashTable<empty, Key, Hash>(hs) + HashTable<nil, Key, Hash>(hs) {} //- Construct by transferring the parameter contents - HashSet(const Xfer<HashTable<empty, Key, Hash> >& hs) + HashSet(const Xfer<HashTable<nil, Key, Hash> >& hs) : - HashTable<empty, Key, Hash>(hs) + HashTable<nil, Key, Hash>(hs) {} //- Construct from table of contents of the HashTable @@ -123,13 +123,13 @@ public: //- Insert a new entry bool insert(const Key& key) { - return HashTable<empty, Key, Hash>::insert(key, empty()); + return HashTable<nil, Key, Hash>::insert(key, nil()); } - //- Same as insert (cannot overwrite empty content) + //- Same as insert (cannot overwrite nil content) bool set(const Key& key) { - return HashTable<empty, Key, Hash>::insert(key, empty()); + return HashTable<nil, Key, Hash>::insert(key, nil()); } diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 0ecc044222e41cef3c71af89a49a8fdda94aa8e1..47cbc6b4c9266efa7fe68df78a88ead4dcabc21a 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -171,6 +171,9 @@ public: //- Return number of elements in table. inline label size() const; + //- Return true if the hash table is empty + inline bool empty() const; + //- Return true if hashedEntry is found in table bool found(const Key&) const; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index 8762d12a9a207c91054857849fe772ab5c26db77..03359b2fd1005a187ab1772273c170cbf1765f40 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -51,6 +51,13 @@ inline Foam::label Foam::HashTable<T, Key, Hash>::size() const } +template<class T, class Key, class Hash> +inline bool Foam::HashTable<T, Key, Hash>::empty() const +{ + return (nElmts_ == 0); +} + + template<class T, class Key, class Hash> inline bool Foam::HashTable<T, Key, Hash>::insert ( diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H index 15044c33e2164d287840aff4a82276c173d1424c..2816056383e59efdad5e8bdb1a230c33972caab6 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H @@ -164,6 +164,9 @@ public: //- Return number of elements in table. inline label size() const; + //- Return true if the hash table is empty + inline bool empty() const; + //- Return true if hashed entry is found in table bool found(const Key& key) const; diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H index 104cbbf3feb8a31ec66a65791e225daa340d2150..93317105a82542bee5d435fb9e648044a994502c 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H @@ -38,6 +38,13 @@ inline Foam::label Foam::StaticHashTable<T, Key, Hash>::size() const } +template<class T, class Key, class Hash> +inline bool Foam::StaticHashTable<T, Key, Hash>::empty() const +{ + return (nElmts_ == 0); +} + + template<class T, class Key, class Hash> inline bool Foam::StaticHashTable<T, Key, Hash>::insert ( diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index 33d55e318625b6312336fdd3377c8ea2661264ce..475109cc7715bbeec46b125efd8f467df22cdf66 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -122,6 +122,9 @@ public: //- Return number of elements in list inline label size() const; + //- Return true if the list is empty + inline bool empty() const; + //- Return first entry inline link* first(); diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H index e30902ce5057ec559537082cca788db5e06ce1d1..6692ce5c525de865e06e2358d141fa503930dd8e 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H @@ -81,6 +81,12 @@ inline Foam::label Foam::DLListBase::size() const } +inline bool Foam::DLListBase::empty() const +{ + return (nElmts_ == 0); +} + + inline Foam::DLListBase::link* Foam::DLListBase::first() { diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H index 4102dee33666511c2b8b6d11f683d7f1a05afcc6..06f5960faec77c034d371844f2244c248d201934 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H @@ -119,6 +119,9 @@ public: //- Return number of elements in list inline label size() const; + //- Return true if the list is empty + inline bool empty() const; + //- Return first entry inline link* first(); diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H index 2d84028e6c5b46dbed81bbe83dbe3542364a5772..ca069a239d7b36f9b7031da84549413f143faf53 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H @@ -71,6 +71,12 @@ inline Foam::label Foam::SLListBase::size() const } +inline bool Foam::SLListBase::empty() const +{ + return (nElmts_ == 0); +} + + inline Foam::SLListBase::link* Foam::SLListBase::first() { diff --git a/src/OpenFOAM/containers/LinkedLists/user/FIFOStack.H b/src/OpenFOAM/containers/LinkedLists/user/FIFOStack.H index 04a6791f244d95e4b8bd5a714ba8759efa2b2b30..a07b94cbcc5b5bbd7b9db8f0070cd3ca1f2a799a 100644 --- a/src/OpenFOAM/containers/LinkedLists/user/FIFOStack.H +++ b/src/OpenFOAM/containers/LinkedLists/user/FIFOStack.H @@ -92,15 +92,6 @@ public: } - // Check - - //- Is the stack empty - bool empty() const - { - return this->size() == 0; - } - - // Edit //- Push an element onto the stack diff --git a/src/OpenFOAM/containers/LinkedLists/user/LIFOStack.H b/src/OpenFOAM/containers/LinkedLists/user/LIFOStack.H index b8bcde265cf55437e8151466c58692e2ad74af53..9e60f35f772979c2b55952df16496de6c8490f79 100644 --- a/src/OpenFOAM/containers/LinkedLists/user/LIFOStack.H +++ b/src/OpenFOAM/containers/LinkedLists/user/LIFOStack.H @@ -92,15 +92,6 @@ public: } - // Check - - //- Is the stack empty - bool empty() const - { - return this->size() == 0; - } - - // Edit //- Push an element onto the stack diff --git a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H index 6e60d13d8afdb41cb9eeffa41490c204e6cd9810..a7827ec6cb3ae771cc61cdc157b0d49d4ef04600 100644 --- a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H +++ b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H @@ -75,6 +75,8 @@ public: // Access inline label size() const; + inline bool empty() const; + inline const UList<T>& posList() const; inline const UList<T>& negList() const; inline const List<label>& addressing() const; diff --git a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H index 8425cb980d3b601df4a18d1af1b1c659e2f9fd32..b30769d107b574a895a1e281cab9a38301ea459b 100644 --- a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H +++ b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H @@ -49,6 +49,13 @@ inline Foam::label Foam::BiIndirectList<T>::size() const } +template<class T> +inline bool Foam::BiIndirectList<T>::empty() const +{ + return addressing_.empty(); +} + + template<class T> inline const Foam::UList<T>& Foam::BiIndirectList<T>::posList() const { diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H index 91a6729706ddb010ddf818f3a5d4046cdc380474..7cf9e31669674529aab97dbf79e492ee4871ded5 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H @@ -126,6 +126,9 @@ public: //- Return the primary size, i.e. the number of rows inline label size() const; + //- Return true if the number of rows is zero + inline bool empty() const; + //- Return the offset table inline const List<label>& offsets() const; diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H index 851609ba7c2369fad2f48c40a6b997ee693404d7..e2e794356ebcfd54dbee95601474f6f87afcf892 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H @@ -74,6 +74,13 @@ inline Foam::label Foam::CompactListList<T>::size() const } +template<class T> +inline bool Foam::CompactListList<T>::empty() const +{ + return offsets_.empty(); +} + + template<class T> inline const Foam::List<Foam::label>& Foam::CompactListList<T>::offsets() const { diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H index 18affc9d064fc102ee5a15e6f133cd658f5e0d9e..776d7b65db7ae58738b4399d37f83de023389272 100644 --- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H +++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H @@ -69,6 +69,8 @@ public: // Access inline label size() const; + inline bool empty() const; + inline const UList<T>& completeList() const; inline const List<label>& addressing() const; diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H index 94a8bbf4b3b2be3c90b3db129eb11472a8e552f8..0ae5311d97ffa56ec064fe05e4b76126978029cb 100644 --- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H +++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H @@ -47,6 +47,13 @@ inline Foam::label Foam::IndirectList<T>::size() const } +template<class T> +inline bool Foam::IndirectList<T>::empty() const +{ + return addressing_.empty(); +} + + template<class T> inline const Foam::UList<T>& Foam::IndirectList<T>::completeList() const { diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index ea75d13eda2be8ca64266f17cf5a7bfa6e4d188a..d2d015ad566308c4a22309bb570457636509ec09 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -166,6 +166,9 @@ public: //- Number of packed elements inline label size() const; + //- Return true if the list is empty (i.e., if size() == 0). + inline bool empty() const; + //- Get value at index I inline unsigned int get(const label i) const; diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H index 809ae08ab5f24a66d2812e4b0766389ddba671be..dc5f18786e8fa437753967cba803fa7c4cc32d57 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H @@ -117,6 +117,13 @@ inline Foam::label Foam::PackedList<nBits>::size() const } +template<int nBits> +inline bool Foam::PackedList<nBits>::empty() const +{ + return (size_ == 0); +} + + // Get value at i template<int nBits> inline unsigned int Foam::PackedList<nBits>::get(const label i) const diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H index b90f0f0b6f8ff857d80dc1e18983507d9b178d67..86c7ea8f4d810193c6d48e9181bfec7ee4c60748 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H @@ -158,6 +158,9 @@ public: //- Return the number of elements in the PtrList inline label size() const; + //- Return true if the PtrList is empty (i.e., if size() == 0). + inline bool empty() const; + // Edit diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H index fe983406cfa24fed1a0a8a677226a31c079cd73e..8dfbe2686ab0a43bf5cf5f5ec72067b847067256 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H @@ -38,6 +38,13 @@ inline Foam::label Foam::PtrList<T>::size() const } +template<class T> +inline bool Foam::PtrList<T>::empty() const +{ + return ptrs_.empty(); +} + + template<class T> inline bool Foam::PtrList<T>::set(const label i) const { diff --git a/src/OpenFOAM/primitives/empty/empty.H b/src/OpenFOAM/primitives/nil/nil.H similarity index 80% rename from src/OpenFOAM/primitives/empty/empty.H rename to src/OpenFOAM/primitives/nil/nil.H index ba1628421c8543f0e534b2be0b170b93d0f079d1..c6fd97eaaf346934a283c9f1586fc18505802d93 100644 --- a/src/OpenFOAM/primitives/empty/empty.H +++ b/src/OpenFOAM/primitives/nil/nil.H @@ -23,20 +23,15 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::empty + Foam::nil Description - A class without storage. Used, for example, in HashSet. - -SourceFiles - emptyI.H - empty.C - emptyIO.C + A class without any storage. Used, for example, in HashSet. \*---------------------------------------------------------------------------*/ -#ifndef empty_H -#define empty_H +#ifndef nil_H +#define nil_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,17 +44,17 @@ class Ostream; // Forward declaration of friend functions and operators -class empty; +class nil; -Istream& operator>>(Istream& is, empty&); -Ostream& operator<<(Ostream& os, const empty&); +Istream& operator>>(Istream&, nil&); +Ostream& operator<<(Ostream&, const nil&); /*---------------------------------------------------------------------------*\ - Class empty Declaration + Class nil Declaration \*---------------------------------------------------------------------------*/ -class empty +class nil { public: @@ -67,22 +62,22 @@ public: // Constructors //- Construct null - empty() + nil() {} //- Construct from Istream - empty(Istream&) + nil(Istream&) {} - // IOstream Operator + // IOstream Operators - friend Istream& operator>>(Istream& is, empty&) + friend Istream& operator>>(Istream& is, nil&) { return is; } - friend Ostream& operator<<(Ostream& os, const empty&) + friend Ostream& operator<<(Ostream& os, const nil&) { return os; }