mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
renamed 'empty' class to 'nil', added missing empty() member to some containers
This commit is contained in:
@ -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>: ";
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -92,15 +92,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Is the stack empty
|
||||
bool empty() const
|
||||
{
|
||||
return this->size() == 0;
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Push an element onto the stack
|
||||
|
||||
@ -92,15 +92,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Is the stack empty
|
||||
bool empty() const
|
||||
{
|
||||
return this->size() == 0;
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Push an element onto the stack
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user