Commit cdb8880c authored by Andrew Heather's avatar Andrew Heather
Browse files

Code clean-up

parent e2eab734
......@@ -109,7 +109,6 @@ struct HashTableCore
{
return iteratorEnd();
}
};
......@@ -139,6 +138,7 @@ class HashTable
//- Construct from key, next pointer and object
inline hashedEntry(const Key&, hashedEntry* next, const T&);
private:
//- Disallow default bitwise copy construct
hashedEntry(const hashedEntry&);
......@@ -209,9 +209,8 @@ public:
HashTable(const Xfer<HashTable<T, Key, Hash> >&);
// Destructor
~HashTable();
//- Destructor
~HashTable();
// Member Functions
......@@ -247,6 +246,7 @@ public:
//- Print information
Ostream& printInfo(Ostream&) const;
// Edit
//- Insert a new hashedEntry
......@@ -291,7 +291,7 @@ public:
void transfer(HashTable<T, Key, Hash>&);
//- Transfer contents to the Xfer container
inline Xfer< HashTable<T, Key, Hash> > xfer();
inline Xfer<HashTable<T, Key, Hash> > xfer();
// Member Operators
......@@ -356,9 +356,8 @@ public:
//- Current hash index
label hashIndex_;
protected:
// Protected Member Functions
protected:
// Constructors
......@@ -380,6 +379,8 @@ public:
);
// Protected Member Functions
//- Increment to the next position
inline void increment();
......@@ -392,6 +393,7 @@ public:
//- Return const access to referenced object
inline const T& cobject() const;
public:
// Member operators
......@@ -434,6 +436,7 @@ public:
const label hashIndex
);
public:
// Constructors
......@@ -444,13 +447,12 @@ public:
//- Construct end iterator
inline iterator(const iteratorEnd& unused);
// Member operators
//- Conversion to a const_iterator
inline operator const_iterator() const;
// Access
//- Return referenced hash value
inline T& operator*();
inline T& operator()();
......@@ -492,6 +494,7 @@ public:
const label hashIndex
);
public:
// Constructors
......@@ -502,9 +505,8 @@ public:
//- Construct end iterator
inline const_iterator(const iteratorEnd& unused);
// Member operators
// Access
// Member operators
//- Return referenced hash value
inline const T& operator*() const;
......@@ -536,7 +538,6 @@ public:
Ostream&,
const HashTable<T, Key, Hash>&
);
};
......
......@@ -97,11 +97,10 @@ Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
{}
template<class T, class Key, class Hash>
Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
(
const Xfer< StaticHashTable<T, Key, Hash> >& ht
const Xfer<StaticHashTable<T, Key, Hash> >& ht
)
:
StaticHashTableCore(),
......@@ -452,7 +451,6 @@ void Foam::StaticHashTable<T, Key, Hash>::clearStorage()
}
template<class T, class Key, class Hash>
void Foam::StaticHashTable<T, Key, Hash>::transfer
(
......
......@@ -72,10 +72,6 @@ template<class T, class Key, class Hash> Ostream& operator<<
);
/*---------------------------------------------------------------------------*\
Class StaticHashTableName Declaration
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
Class StaticHashTableCore Declaration
\*---------------------------------------------------------------------------*/
......@@ -100,7 +96,6 @@ struct StaticHashTableCore
iteratorEnd()
{}
};
};
......@@ -135,6 +130,7 @@ class StaticHashTable
//- Assign a new hashed entry to a possibly already existing key
bool set(const Key&, const T& newElmt, bool protect);
public:
......@@ -183,11 +179,11 @@ public:
StaticHashTable(const StaticHashTable<T, Key, Hash>&);
//- Construct by transferring the parameter contents
StaticHashTable(const Xfer< StaticHashTable<T, Key, Hash> >&);
StaticHashTable(const Xfer<StaticHashTable<T, Key, Hash> >&);
// Destructor
~StaticHashTable();
//- Destructor
~StaticHashTable();
// Member Functions
......@@ -251,7 +247,7 @@ public:
void transfer(StaticHashTable<T, Key, Hash>&);
//- Transfer contents to the Xfer container
inline Xfer< StaticHashTable<T, Key, Hash> > xfer();
inline Xfer<StaticHashTable<T, Key, Hash> > xfer();
// Member Operators
......@@ -275,6 +271,7 @@ public:
//- The opposite of the equality operation.
bool operator!=(const StaticHashTable<T, Key, Hash>&) const;
// STL type definitions
//- Type of values the StaticHashTable contains.
......@@ -317,6 +314,7 @@ public:
//- Index of current element at hashIndex
label elemIndex_;
public:
// Constructors
......
......@@ -79,7 +79,7 @@ inline bool Foam::StaticHashTable<T, Key, Hash>::set
template<class T, class Key, class Hash>
inline Foam::Xfer< Foam::StaticHashTable<T, Key, Hash> >
inline Foam::Xfer<Foam::StaticHashTable<T, Key, Hash> >
Foam::StaticHashTable<T, Key, Hash>::xfer()
{
return xferMove(*this);
......@@ -417,6 +417,4 @@ Foam::StaticHashTable<T, Key, Hash>::end() const
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //
......@@ -74,7 +74,7 @@ public:
(
const UList<T>& posList,
const UList<T>& negList,
const Xfer< List<label> >&
const Xfer<List<label> >&
);
......@@ -102,7 +102,7 @@ public:
//- Reset addressing
inline void resetAddressing(const UList<label>&);
inline void resetAddressing(const Xfer< List<label> >&);
inline void resetAddressing(const Xfer<List<label> >&);
// Member Operators
......
......@@ -45,7 +45,7 @@ inline Foam::BiIndirectList<T>::BiIndirectList
(
const UList<T>& posList,
const UList<T>& negList,
const Xfer< List<label> >& addr
const Xfer<List<label> >& addr
)
:
posList_(const_cast<UList<T>&>(posList)),
......@@ -105,7 +105,7 @@ inline void Foam::BiIndirectList<T>::resetAddressing
template<class T>
inline void Foam::BiIndirectList<T>::resetAddressing
(
const Xfer< List<label> >& addr
const Xfer<List<label> >& addr
)
{
addressing_.transfer(addr());
......
......@@ -84,7 +84,6 @@ class DynamicList
//- The capacity (allocated size) of the underlying list.
label capacity_;
// Private Member Functions
public:
......@@ -93,6 +92,7 @@ public:
//- Declare friendship with the List class
friend class List<T>;
// Constructors
//- Construct null
......@@ -115,7 +115,7 @@ public:
explicit inline DynamicList(const UIndirectList<T>&);
//- Construct by transferring the parameter contents
explicit inline DynamicList(const Xfer< List<T> >&);
explicit inline DynamicList(const Xfer<List<T> >&);
//- Construct from Istream. Size set to size of read list.
explicit DynamicList(Istream&);
......@@ -125,103 +125,105 @@ public:
// Access
//- Size of the underlying storage.
inline label capacity() const;
//- Size of the underlying storage.
inline label capacity() const;
// Edit
//- Alter the size of the underlying storage.
// The addressed size will be truncated if needed to fit, but will
// remain otherwise untouched.
// Use this or reserve() in combination with append().
inline void setCapacity(const label);
//- Alter the size of the underlying storage.
// The addressed size will be truncated if needed to fit, but will
// remain otherwise untouched.
// Use this or reserve() in combination with append().
inline void setCapacity(const label);
//- Alter the addressed list size.
// New space will be allocated if required.
// Use this to resize the list prior to using the operator[] for
// setting values (as per List usage).
inline void setSize(const label);
//- Alter the addressed list size.
// New space will be allocated if required.
// Use this to resize the list prior to using the operator[] for
// setting values (as per List usage).
inline void setSize(const label);
//- Alter the addressed list size and fill new space with a constant.
inline void setSize(const label, const T&);
//- Alter the addressed list size and fill new space with a constant.
inline void setSize(const label, const T&);
//- Alter the addressed list size.
// New space will be allocated if required.
// Use this to resize the list prior to using the operator[] for
// setting values (as per List usage).
inline void resize(const label);
//- Alter the addressed list size.
// New space will be allocated if required.
// Use this to resize the list prior to using the operator[] for
// setting values (as per List usage).
inline void resize(const label);
//- Alter the addressed list size and fill new space with a constant.
inline void resize(const label, const T&);
//- Alter the addressed list size and fill new space with a constant.
inline void resize(const label, const T&);
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size, use setCapacity() for that.
inline void reserve(const label);
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size, use setCapacity() for that.
inline void reserve(const label);
//- Clear the addressed list, i.e. set the size to zero.
// Allocated size does not change
inline void clear();
//- Clear the addressed list, i.e. set the size to zero.
// Allocated size does not change
inline void clear();
//- Clear the list and delete storage.
inline void clearStorage();
//- Clear the list and delete storage.
inline void clearStorage();
//- Shrink the allocated space to the number of elements used.
// Returns a reference to the DynamicList.
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& shrink();
//- Shrink the allocated space to the number of elements used.
// Returns a reference to the DynamicList.
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& shrink();
//- Transfer contents of the argument List into this DynamicList
inline void transfer(List<T>&);
//- Transfer contents of the argument List into this DynamicList
inline void transfer(List<T>&);
//- Transfer contents of the argument DynamicList into this DynamicList
inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
//- Transfer contents of the argument DynamicList into this DynamicList
inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
//- Transfer contents to the Xfer container as a plain List
inline Xfer< List<T> > xfer();
//- Transfer contents to the Xfer container as a plain List
inline Xfer<List<T> > xfer();
// Member Operators
//- Append an element at the end of the list
inline void append(const T&);
// Member Operators
//- Append a List at the end of this list
inline void append(const UList<T>&);
//- Append an element at the end of the list
inline void append(const T&);
//- Append a UIndirectList at the end of this list
inline void append(const UIndirectList<T>&);
//- Append a List at the end of this list
inline void append(const UList<T>&);
//- Remove and return the top element
inline T remove();
//- Append a UIndirectList at the end of this list
inline void append(const UIndirectList<T>&);
//- Return non-const access to an element, resizing list if necessary
inline T& operator()(const label);
//- Remove and return the top element
inline T remove();
//- Assignment of all addressed entries to the given value
inline void operator=(const T&);
//- Return non-const access to an element, resizing list if necessary
inline T& operator()(const label);
//- Assignment from DynamicList
inline void operator=
(
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
);
//- Assignment of all addressed entries to the given value
inline void operator=(const T&);
//- Assignment from UList
inline void operator=(const UList<T>&);
//- Assignment from DynamicList
inline void operator=
(
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
);
// IOstream operators
//- Assignment from UList
inline void operator=(const UList<T>&);
// Write DynamicList to Ostream.
friend Ostream& operator<< <T, SizeInc, SizeMult, SizeDiv>
(
Ostream&,
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
);
//- Read from Istream, discarding contents of existing DynamicList.
friend Istream& operator>> <T, SizeInc, SizeMult, SizeDiv>
(
Istream&,
DynamicList<T, SizeInc, SizeMult, SizeDiv>&
);
// IOstream operators
// Write DynamicList to Ostream.
friend Ostream& operator<< <T, SizeInc, SizeMult, SizeDiv>
(
Ostream&,
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
);
//- Read from Istream, discarding contents of existing DynamicList.
friend Istream& operator>> <T, SizeInc, SizeMult, SizeDiv>
(
Istream&,
DynamicList<T, SizeInc, SizeMult, SizeDiv>&
);
};
......
......@@ -298,7 +298,7 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::Xfer< Foam::List<T> >
inline Foam::Xfer<Foam::List<T> >
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::xfer()
{
return xferMoveTo< List<T> >(*this);
......
......@@ -64,7 +64,8 @@ public:
inline IndirectList(const UList<T>&, const UList<label>&);
//- Construct given the complete list and by transferring addressing
inline IndirectList(const UList<T>&, const Xfer< List<label> >&);
inline IndirectList(const UList<T>&, const Xfer<List<label> >&);
// Member Functions
......@@ -94,11 +95,12 @@ public:
//- Return the list addressing
inline const List<label>& addressing() const;
// Edit
//- Reset addressing
inline void resetAddressing(const UList<label>&);
inline void resetAddressing(const Xfer< List<label> >&);
inline void resetAddressing(const Xfer<List<label> >&);
// Member Operators
......
......@@ -42,7 +42,7 @@ template<class T>
inline Foam::IndirectList<T>::IndirectList
(
const UList<T>& completeList,
const Xfer< List<label> >& addr
const Xfer<List<label> >& addr
)
:
completeList_(const_cast<UList<T>&>(completeList)),
......@@ -121,7 +121,7 @@ inline void Foam::IndirectList<T>::resetAddressing
template<class T>
inline void Foam::IndirectList<T>::resetAddressing
(
const Xfer< List<label> >& addr
const Xfer<List<label> >& addr
)
{
addressing_.transfer(addr());
......
......@@ -114,7 +114,7 @@ Foam::List<T>::List(const List<T>& a)
// Construct by transferring the parameter contents
template<class T>
Foam::List<T>::List(const Xfer< List<T> >& lst)
Foam::List<T>::List(const Xfer<List<T> >& lst)
{
transfer(lst());
}
......
......@@ -87,6 +87,7 @@ protected:
// Use with care.
inline void size(const label);
public:
// Static Member Functions
......@@ -109,7 +110,7 @@ public:
List(const List<T>&);
//- Construct by transferring the parameter contents
List(const Xfer< List<T> >&);
List(const Xfer<List<T> >&);
//- Construct as copy or re-use as specified.
List(List<T>&, bool reUse);
......@@ -147,9 +148,8 @@ public:
inline autoPtr<List<T> > clone() const;
// Destructor
~List();
//- Destructor
~List();
// Related types
......@@ -201,7 +201,7 @@ public:
void transfer(SortableList<T>&);
//- Transfer contents to the Xfer container
inline Xfer< List<T> > xfer();
inline Xfer<List<T> > xfer();
//- Return subscript-checked element of UList.
inline T& newElmt(const label);
......
......@@ -88,7 +88,7 @@ inline Foam::label Foam::List<T>::size() const
template<class T>
inline Foam::Xfer< Foam::List<T> > Foam::List<T>::xfer()
inline Foam::Xfer<Foam::List<T> > Foam::List<T>::xfer()
{
return xferMove(*this);
}
......
......@@ -132,6 +132,7 @@ class PackedList
//- Calculate the list length when packed
inline static label packedLength(const label);
public:
// Public data
......@@ -150,12 +151,14 @@ public:
//- Masking for all bits below the offset
inline static unsigned int maskLower(unsigned offset);
// Forward declaration of iterators
class iteratorBase;
class iterator;
class const_iterator;
// Constructors
//- Null constructor
......@@ -171,7 +174,7 @@ public:
inline PackedList(const PackedList<nBits>&);
//- Construct by transferring the parameter contents
inline PackedList(const Xfer< PackedList<nBits> >&);
inline PackedList(const Xfer<PackedList<nBits> >&);
//- Construct from a list of labels
explicit PackedList(const UList<label>&);
......@@ -179,123 +182,126 @@ public:
//- Clone
inline autoPtr< PackedList<nBits> > clone() const;
// Member Functions
// Access
//- The number of elements that can be stored before reallocating
inline label capacity() const;
//- The number of elements that can be stored before reallocating