diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 2fbb548d0e6ae2b7b256a40a560c0f7dee6678ec..457e2f1b7e55119d0cbc7bba2be465ab63abad68 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -384,6 +384,12 @@ public: }; + //- const_iterator set to the beginning of the HashTable + inline const_iterator cbegin() const; + + //- const_iterator set to beyond the end of the HashTable + inline const const_iterator& cend() const; + //- const_iterator set to the beginning of the HashTable inline const_iterator begin() const; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index 03359b2fd1005a187ab1772273c170cbf1765f40..79ff3741453e3863093e73492307da9a636294bd 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -452,7 +452,7 @@ const Key& Foam::HashTable<T, Key, Hash>::const_iterator::key() template<class T, class Key, class Hash> inline typename Foam::HashTable<T, Key, Hash>::const_iterator -Foam::HashTable<T, Key, Hash>::begin() const +Foam::HashTable<T, Key, Hash>::cbegin() const { label i = 0; @@ -477,6 +477,22 @@ Foam::HashTable<T, Key, Hash>::begin() const } +template<class T, class Key, class Hash> +inline const typename Foam::HashTable<T, Key, Hash>::const_iterator& +Foam::HashTable<T, Key, Hash>::cend() const +{ + return HashTable<T, Key, Hash>::endConstIter_; +} + + +template<class T, class Key, class Hash> +inline typename Foam::HashTable<T, Key, Hash>::const_iterator +Foam::HashTable<T, Key, Hash>::begin() const +{ + return this->cbegin(); +} + + template<class T, class Key, class Hash> inline const typename Foam::HashTable<T, Key, Hash>::const_iterator& Foam::HashTable<T, Key, Hash>::end() const diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H index 2816056383e59efdad5e8bdb1a230c33972caab6..4513ea02452f91125e855dbb37cfc119ca825377 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H @@ -317,19 +317,24 @@ public: }; - //- iterator set to the begining of the StaticHashTable + //- iterator set to the beginning of the StaticHashTable inline iterator begin(); //- iterator set to beyond the end of the StaticHashTable inline const iterator& end(); - //- const_iterator set to the begining of the StaticHashTable + //- const_iterator set to the beginning of the StaticHashTable + inline const_iterator cbegin() const; + + //- const_iterator set to beyond the end of the StaticHashTable + inline const const_iterator& cend() const; + + //- const_iterator set to the beginning of the StaticHashTable inline const_iterator begin() const; //- const_iterator set to beyond the end of the StaticHashTable inline const const_iterator& end() const; - // IOstream Operator friend Istream& operator>> <T, Key, Hash> diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H index d9bfaae0b809e658fcab2064c1c1b8acc47f3e68..329437a07a40d774545c36cbb23a80b5db65a383 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H @@ -355,7 +355,7 @@ Foam::StaticHashTable<T, Key, Hash>::end() template<class T, class Key, class Hash> inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator -Foam::StaticHashTable<T, Key, Hash>::begin() const +Foam::StaticHashTable<T, Key, Hash>::cbegin() const { // Find first non-empty entry forAll(keys_, hashIdx) @@ -377,6 +377,22 @@ Foam::StaticHashTable<T, Key, Hash>::begin() const } +template<class T, class Key, class Hash> +inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator& +Foam::StaticHashTable<T, Key, Hash>::cend() const +{ + return StaticHashTable<T, Key, Hash>::endConstIter_; +} + + +template<class T, class Key, class Hash> +inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator +Foam::StaticHashTable<T, Key, Hash>::begin() const +{ + return this->cbegin(); +} + + template<class T, class Key, class Hash> inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator& Foam::StaticHashTable<T, Key, Hash>::end() const diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C index 5c21dfe58e698d39642bee798cd7c72f125d1db4..78a4313a90a74aeda287e1a4275e0bfba554928c 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C @@ -30,14 +30,14 @@ License #include "IOstreams.H" #include "long.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -Foam::DLListBase::iterator Foam::DLListBase::endIter +Foam::DLListBase::iterator Foam::DLListBase::endIter_ ( const_cast<DLListBase&>(static_cast<const DLListBase&>(DLListBase())) ); -Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter +Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter_ ( static_cast<const DLListBase&>(DLListBase()), reinterpret_cast<const link*>(0) diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index 475109cc7715bbeec46b125efd8f467df22cdf66..ba3423c8e2c04630a059d23bde5020dee9f653d8 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -176,7 +176,7 @@ public: // STL iterator - //- An STL iterator + //- An STL-conforming iterator class iterator { friend class DLListBase; @@ -193,16 +193,17 @@ public: //- Copy of the link link curLink_; + // Private Member Functions + + //- Construct for a given SLListBase with NULL element and link. + // Only used to create endIter + inline iterator(DLListBase&); + public: //- Construct for a given DLListBase and link inline iterator(DLListBase&, link*); - //- Construct for a given DLListBase - // setting element and link to NULL. - // Only used to create endIter - inline iterator(DLListBase&); - // Member operators inline void operator=(const iterator&); @@ -217,16 +218,12 @@ public: }; inline iterator begin(); - - //- iterator returned by end() - static iterator endIter; - inline const iterator& end(); // STL const_iterator - //- An STL const_iterator + //- An STL-conforming const_iterator class const_iterator { // Private data @@ -258,12 +255,20 @@ public: inline const_iterator operator++(int); }; + inline const_iterator cbegin() const; + inline const const_iterator& cend() const; + inline const_iterator begin() const; + inline const const_iterator& end() const; + +private: + + //- iterator returned by end() + static iterator endIter_; //- const_iterator returned by end() - static const_iterator endConstIter; + static const_iterator endConstIter_; - inline const const_iterator& end() const; }; diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H index 6692ce5c525de865e06e2358d141fa503930dd8e..9b80941bf9abaa9679b0df74c29769f15879bea1 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H @@ -259,14 +259,14 @@ Foam::DLListBase::begin() } else { - return endIter; + return endIter_; } } inline const Foam::DLListBase::iterator& Foam::DLListBase::end() { - return endIter; + return endIter_; } @@ -350,7 +350,7 @@ Foam::DLListBase::const_iterator::operator++(int) inline Foam::DLListBase::const_iterator -Foam::DLListBase::begin() const +Foam::DLListBase::cbegin() const { if (size()) { @@ -358,15 +358,29 @@ Foam::DLListBase::begin() const } else { - return endConstIter; + return endConstIter_; } } +inline const Foam::DLListBase::const_iterator& +Foam::DLListBase::cend() const +{ + return endConstIter_; +} + + +inline Foam::DLListBase::const_iterator +Foam::DLListBase::begin() const +{ + return this->cbegin(); +} + + inline const Foam::DLListBase::const_iterator& Foam::DLListBase::end() const { - return endConstIter; + return endConstIter_; } diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C index 75dca644d99b4b9d810f609cc5a22c9c22cabaec..f0fb24baac28e7863fec3a516ff3e9d5996101d3 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C @@ -29,12 +29,12 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::SLListBase::iterator Foam::SLListBase::endIter +Foam::SLListBase::iterator Foam::SLListBase::endIter_ ( const_cast<SLListBase&>(static_cast<const SLListBase&>(SLListBase())) ); -Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter +Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter_ ( static_cast<const SLListBase&>(SLListBase()), reinterpret_cast<const link*>(0) diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H index 06f5960faec77c034d371844f2244c248d201934..4f660a1e4d02f669547bc6dd542bbf4813fe78b1 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H @@ -178,16 +178,16 @@ public: //- Copy of the link link curLink_; - public: + // Private Member Functions - //- Construct for a given SLListBase and link - inline iterator(SLListBase&, link*); - - //- Construct for a given SLListBase - // setting element and link to NULL. + //- Construct for a given SLListBase with NULL element and link. // Only used to create endIter inline iterator(SLListBase&); + public: + + //- Construct for a given SLListBase and link + inline iterator(SLListBase&, link*); // Member operators @@ -203,10 +203,6 @@ public: }; inline iterator begin(); - - //- iterator returned by end() - static iterator endIter; - inline const iterator& end(); @@ -245,12 +241,20 @@ public: inline const_iterator operator++(int); }; + inline const_iterator cbegin() const; + inline const const_iterator& cend() const; + inline const_iterator begin() const; + inline const const_iterator& end() const; + +private: + + //- iterator returned by end() + static iterator endIter_; //- const_iterator returned by end() - static const_iterator endConstIter; + static const_iterator endConstIter_; - inline const const_iterator& end() const; }; diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H index ca069a239d7b36f9b7031da84549413f143faf53..de34257d342f82751ebce088b4edd349744d684d 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H @@ -231,7 +231,7 @@ Foam::SLListBase::begin() } else { - return endIter; + return endIter_; } } @@ -239,7 +239,7 @@ Foam::SLListBase::begin() inline const Foam::SLListBase::iterator& Foam::SLListBase::end() { - return endIter; + return endIter_; } @@ -323,7 +323,7 @@ Foam::SLListBase::const_iterator::operator++(int) inline Foam::SLListBase::const_iterator -Foam::SLListBase::begin() const +Foam::SLListBase::cbegin() const { if (size()) { @@ -331,15 +331,29 @@ Foam::SLListBase::begin() const } else { - return endConstIter; + return endConstIter_; } } +inline const Foam::SLListBase::const_iterator& +Foam::SLListBase::cend() const +{ + return endConstIter_; +} + + +inline Foam::SLListBase::const_iterator +Foam::SLListBase::begin() const +{ + return this->cbegin(); +} + + inline const Foam::SLListBase::const_iterator& Foam::SLListBase::end() const { - return endConstIter; + return endConstIter_; } diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C index 2602eea95a6569ef342b2ceee014412d155603b6..8e802fe48ea5453089c9073d792d15108ed4284c 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C @@ -142,12 +142,17 @@ void Foam::CompactListList<T>::setSize(const label nRows) template<class T> -void Foam::CompactListList<T>::setSize(const label nRows, const label nData) +void Foam::CompactListList<T>::setSize +( + const label nRows, + const label nData +) { offsets_.setSize(nRows); m_.setSize(nData); } + template<class T> void Foam::CompactListList<T>::setSize ( @@ -160,19 +165,6 @@ void Foam::CompactListList<T>::setSize m_.setSize(nData, t); } -template<class T> -Foam::labelList Foam::CompactListList<T>::sizes() const -{ - labelList rowSizes(offsets_.size()); - - label prevOffset = 0; - forAll(offsets_, i) - { - rowSizes[i] = offsets_[i]-prevOffset; - prevOffset = offsets_[i]; - } - return rowSizes; -} template<class T> void Foam::CompactListList<T>::setSize(const UList<label>& rowSizes) @@ -189,6 +181,22 @@ void Foam::CompactListList<T>::setSize(const UList<label>& rowSizes) m_.setSize(sumSize); } + +template<class T> +Foam::labelList Foam::CompactListList<T>::sizes() const +{ + labelList rowSizes(offsets_.size()); + + label prevOffset = 0; + forAll(offsets_, i) + { + rowSizes[i] = offsets_[i]-prevOffset; + prevOffset = offsets_[i]; + } + return rowSizes; +} + + template<class T> void Foam::CompactListList<T>::clear() { diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H index 18943d268f3f67179dee8161240d39bb4f90506d..f0a80cc1bd8eacd86f6f65b87f07ed9002ce4335 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H @@ -156,15 +156,28 @@ public: //- Reset sizes of CompactListList and value for new elements. void setSize(const label nRows, const label nData, const T&); - //- Return sizes (to be used e.g. for construction) - labelList sizes() const; - //- Reset size of CompactListList. void setSize(const UList<label>& rowSizes); + //- Reset size of CompactListList. + // This form only allows contraction of the CompactListList. + inline void resize(const label nRows); + + //- Reset size of CompactListList. + inline void resize(const label nRows, const label nData); + + //- Reset sizes of CompactListList and value for new elements. + inline void resize(const label nRows, const label nData, const T&); + + //- Reset size of CompactListList. + inline void resize(const UList<label>& rowSizes); + //- Clear the CompactListList, i.e. set sizes to zero. void clear(); + //- Return sizes (to be used e.g. for construction) + labelList sizes() const; + //- Transfer the contents of the argument CompactListList // into this CompactListList and annull the argument list. void transfer(CompactListList<T>&); diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H index 58e9590199fa1e608be399210c1a9fe3a74b6934..dc57627911d5c63e8175b059731bf6d1ded3f27e 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H @@ -176,6 +176,43 @@ inline Foam::Xfer<Foam::CompactListList<T> > Foam::CompactListList<T>::xfer() } +template<class T> +inline void Foam::CompactListList<T>::resize(const label nRows) +{ + this->setSize(nRows); +} + + +template<class T> +inline void Foam::CompactListList<T>::resize +( + const label nRows, + const label nData +) +{ + this->setSize(nRows, nData); +} + + +template<class T> +inline void Foam::CompactListList<T>::resize +( + const label nRows, + const label nData, + const T& t +) +{ + this->setSize(nRows, nData, t); +} + + +template<class T> +inline void Foam::CompactListList<T>::resize(const UList<label>& rowSizes) +{ + this->setSize(rowSizes); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T> diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index 1e62ceb96c938819917bfc4800e7c58f34f8b617..47e7c4b200936d6457ff63c985ae32e3a4379da1 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -142,6 +142,15 @@ public: //- 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 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); diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index 5f65f0e665762a1bf82ce369234ff7c1985701dd..5fe561e0f2820504e0ca50e99af96357ddf9da11 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -207,6 +207,27 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize } +template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize +( + const label nElem +) +{ + this->setSize(nElem); +} + + +template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize +( + const label nElem, + const T& t +) +{ + this->setSize(nElem, t); +} + + template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clear() { diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 40f0bb24f092cd5b24d7803de48d6fce6c274c29..2e3ddf408bd474e74a46f3f51e5bf3387d96051f 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -153,6 +153,10 @@ public: // Edit + //- Dummy resize function + // needed to make FixedList consistent with List + inline void resize(const label); + //- Dummy setSize function // needed to make FixedList consistent with List inline void setSize(const label); @@ -227,12 +231,16 @@ public: //- Random access iterator for traversing FixedList. typedef const T* const_iterator; - //- Return a const_iterator to begin traversing the - // constant FixedList. + //- Return const_iterator to begin traversing the constant FixedList. + inline const_iterator cbegin() const; + + //- Return const_iterator to end traversing the constant FixedList. + inline const_iterator cend() const; + + //- Return const_iterator to begin traversing the constant FixedList. inline const_iterator begin() const; - //- Return a const_iterator to end traversing the - // constant FixedList. + //- Return const_iterator to end traversing the constant FixedList. inline const_iterator end() const; @@ -241,12 +249,10 @@ public: //- Reverse iterator for reverse traversal of FixedList. typedef T* reverse_iterator; - //- Return a reverse_iterator to begin reverse traversing the - // FixedList. + //- Return reverse_iterator to begin reverse traversing the FixedList. inline reverse_iterator rbegin(); - //- Return a reverse_iterator to end reverse traversing the - // FixedList. + //- Return reverse_iterator to end reverse traversing the FixedList. inline reverse_iterator rend(); @@ -255,12 +261,16 @@ public: //- Reverse iterator for reverse traversal of constant FixedList. typedef const T* const_reverse_iterator; - //- Return a const_reverse_iterator to begin reverse traversing the - // FixedList. + //- Return const_reverse_iterator to begin reverse traversing FixedList. + inline const_reverse_iterator crbegin() const; + + //- Return const_reverse_iterator to end reverse traversing FixedList. + inline const_reverse_iterator crend() const; + + //- Return const_reverse_iterator to begin reverse traversing FixedList. inline const_reverse_iterator rbegin() const; - //- Return a const_reverse_iterator to end reverse traversing the - // FixedList. + //- Return const_reverse_iterator to end reverse traversing FixedList. inline const_reverse_iterator rend() const; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index e58d500ffde2d4e5167130ae7c68c30ebe09679b..d618cb6e386751b804e433228c8633b5a4914e5d 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -170,6 +170,14 @@ inline void Foam::FixedList<T, Size>::checkIndex(const label i) const } +template<class T, Foam::label Size> +inline void Foam::FixedList<T, Size>::resize(const label s) +{ +# ifdef FULLDEBUG + checkSize(s); +# endif +} + template<class T, Foam::label Size> inline void Foam::FixedList<T, Size>::setSize(const label s) { @@ -276,6 +284,14 @@ Foam::FixedList<T, Size>::begin() const } +template<class T, Foam::label Size> +inline typename Foam::FixedList<T, Size>::const_iterator +Foam::FixedList<T, Size>::cbegin() const +{ + return v_; +} + + template<class T, Foam::label Size> inline typename Foam::FixedList<T, Size>::iterator Foam::FixedList<T, Size>::end() @@ -291,6 +307,15 @@ Foam::FixedList<T, Size>::end() const return &v_[Size]; } + +template<class T, Foam::label Size> +inline typename Foam::FixedList<T, Size>::const_iterator +Foam::FixedList<T, Size>::cend() const +{ + return &v_[Size]; +} + + template<class T, Foam::label Size> inline typename Foam::FixedList<T, Size>::iterator Foam::FixedList<T, Size>::rbegin() @@ -307,6 +332,14 @@ Foam::FixedList<T, Size>::rbegin() const } +template<class T, Foam::label Size> +inline typename Foam::FixedList<T, Size>::const_iterator +Foam::FixedList<T, Size>::crbegin() const +{ + return &v_[Size-1]; +} + + template<class T, Foam::label Size> inline typename Foam::FixedList<T, Size>::iterator Foam::FixedList<T, Size>::rend() @@ -323,6 +356,14 @@ Foam::FixedList<T, Size>::rend() const } +template<class T, Foam::label Size> +inline typename Foam::FixedList<T, Size>::const_iterator +Foam::FixedList<T, Size>::crend() const +{ + return &v_[-1]; +} + + template<class T, Foam::label Size> inline Foam::label Foam::FixedList<T, Size>::size() const { diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 11431b4daf1e0eff89021b2aca3b1946cb8e4630..983b2be0081e2363310abd46f41c64dbf823d6aa 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -158,6 +158,12 @@ public: // Edit + //- Reset size of List. + inline void resize(const label); + + //- Reset size of List and value for new elements. + inline void resize(const label, const T&); + //- Reset size of List. void setSize(const label); diff --git a/src/OpenFOAM/containers/Lists/List/ListI.H b/src/OpenFOAM/containers/Lists/List/ListI.H index a0b728670812d085bf5cf48e8df06017ba758757..c3c6ebe4fb691eb7aed7470cd874d6f9015f0fcb 100644 --- a/src/OpenFOAM/containers/Lists/List/ListI.H +++ b/src/OpenFOAM/containers/Lists/List/ListI.H @@ -47,6 +47,20 @@ inline const Foam::List<T>& Foam::List<T>::null() } +template<class T> +inline void Foam::List<T>::resize(const label newSize) +{ + this->setSize(newSize); +} + + +template<class T> +inline void Foam::List<T>::resize(const label newSize, const T& a) +{ + this->setSize(newSize, a); +} + + template<class T> inline T& Foam::List<T>::newElmt(const label i) { diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index d2d015ad566308c4a22309bb570457636509ec09..92493d557db2bb1fe9691d5b6f714d9cd3fd09cb 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -150,6 +150,9 @@ public: //- Reset size of List. void setSize(const label); + //- Reset size of List. + inline void resize(const label); + //- Clear the list, i.e. set size to zero. void clear(); diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H index dc5f18786e8fa437753967cba803fa7c4cc32d57..3ccd2578139897d86bc0c3cd5213fbcd2e40f502 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H @@ -110,6 +110,13 @@ inline Foam::PackedList<nBits>::PackedList(const label size) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template<int nBits> +inline void Foam::PackedList<nBits>::resize(const label size) +{ + this->setSize(size); +} + + template<int nBits> inline Foam::label Foam::PackedList<nBits>::size() const { diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H index 86c7ea8f4d810193c6d48e9181bfec7ee4c60748..5de1345f10d6069e0534f4f9aa0811858590b667 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H @@ -170,6 +170,12 @@ public: // deleted. void setSize(const label); + //- Reset size of PtrList. This can only be used to set the size + // of an empty PtrList, extend a PtrList, remove entries from + // the end of a PtrList. If the entries are non-empty they are + // deleted. + inline void resize(const label); + //- Clear the PtrList, i.e. set size to zero deleting all the // allocated entries. void clear(); diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H index 8dfbe2686ab0a43bf5cf5f5ec72067b847067256..d450cdd09fe7107d975d338031f066878be7fca1 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H @@ -45,6 +45,13 @@ inline bool Foam::PtrList<T>::empty() const } +template<class T> +inline void Foam::PtrList<T>::resize(const label newSize) +{ + this->setSize(newSize); +} + + template<class T> inline bool Foam::PtrList<T>::set(const label i) const { diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index bf3dc84802684c4986e8ef8ee6ac6e5c713e37c9..83c0913a5fee09a44c548ab396a24d512b641314 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -215,12 +215,16 @@ public: //- Random access iterator for traversing UList. typedef const T* const_iterator; - //- Return a const_iterator to begin traversing the - // constant UList. + //- Return const_iterator to begin traversing the constant UList. + inline const_iterator cbegin() const; + + //- Return const_iterator to end traversing the constant UList. + inline const_iterator cend() const; + + //- Return const_iterator to begin traversing the constant UList. inline const_iterator begin() const; - //- Return a const_iterator to end traversing the - // constant UList. + //- Return const_iterator to end traversing the constant UList. inline const_iterator end() const; @@ -229,12 +233,10 @@ public: //- Reverse iterator for reverse traversal of UList. typedef T* reverse_iterator; - //- Return a reverse_iterator to begin reverse traversing the - // UList. + //- Return reverse_iterator to begin reverse traversing the UList. inline reverse_iterator rbegin(); - //- Return a reverse_iterator to end reverse traversing the - // UList. + //- Return reverse_iterator to end reverse traversing the UList. inline reverse_iterator rend(); @@ -243,12 +245,16 @@ public: //- Reverse iterator for reverse traversal of constant UList. typedef const T* const_reverse_iterator; - //- Return a const_reverse_iterator to begin reverse traversing the - // UList. + //- Return const_reverse_iterator to begin reverse traversing the UList. + inline const_reverse_iterator crbegin() const; + + //- Return const_reverse_iterator to end reverse traversing the UList. + inline const_reverse_iterator crend() const; + + //- Return const_reverse_iterator to begin reverse traversing the UList. inline const_reverse_iterator rbegin() const; - //- Return a const_reverse_iterator to end reverse traversing the - // UList. + //- Return const_reverse_iterator to end reverse traversing the UList. inline const_reverse_iterator rend() const; diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index e6fbb5230b9411f6e7fe8eb5963da0bd1e8df5d4..7d8d87006c8420fe6b7f5b79554c2590fee69f19 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -161,6 +161,13 @@ Foam::UList<T>::begin() const return v_; } +template<class T> +inline typename Foam::UList<T>::const_iterator +Foam::UList<T>::cbegin() const +{ + return v_; +} + template<class T> inline typename Foam::UList<T>::iterator Foam::UList<T>::end() @@ -175,6 +182,13 @@ Foam::UList<T>::end() const return &v_[size_]; } +template<class T> +inline typename Foam::UList<T>::const_iterator +Foam::UList<T>::cend() const +{ + return &v_[size_]; +} + template<class T> inline typename Foam::UList<T>::iterator Foam::UList<T>::rbegin() @@ -189,6 +203,13 @@ Foam::UList<T>::rbegin() const return &v_[size_-1]; } +template<class T> +inline typename Foam::UList<T>::const_iterator +Foam::UList<T>::crbegin() const +{ + return &v_[size_-1]; +} + template<class T> inline typename Foam::UList<T>::iterator Foam::UList<T>::rend() @@ -203,6 +224,13 @@ Foam::UList<T>::rend() const return &v_[-1]; } +template<class T> +inline typename Foam::UList<T>::const_iterator +Foam::UList<T>::crend() const +{ + return &v_[-1]; +} + template<class T> inline Foam::label Foam::UList<T>::size() const { diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H index 05e0078701d3714112cbb0ca99eda8d4d72f3e66..cfcae367184a3b656c83e7d4d425d4e184e19781 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H @@ -124,6 +124,9 @@ public: //- Return the number of elements in the UPtrList inline label size() const; + //- Return true if the UPtrList is empty (i.e., if size() == 0). + inline bool empty() const; + // Edit @@ -132,6 +135,11 @@ public: // the end of a UPtrList. void setSize(const label); + //- Reset size of UPtrList. This can only be used to set the size + // of an empty UPtrList, extend a UPtrList, remove entries from + // the end of a UPtrList. + inline void resize(const label); + //- Clear the UPtrList, i.e. set size to zero void clear(); diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H index 73663843d8631c69049856fc1d93a022e0c7c78d..859f54fce5f7d45b2cb278be640db627183d7ceb 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H @@ -35,13 +35,26 @@ inline Foam::label Foam::UPtrList<T>::size() const } +template<class T> +inline bool Foam::UPtrList<T>::empty() const +{ + return ptrs_.empty(); +} + + +template<class T> +inline void Foam::UPtrList<T>::resize(const label newSize) +{ + this->setSize(newSize); +} + + template<class T> inline bool Foam::UPtrList<T>::set(const label i) const { return ptrs_[i] != NULL; } - template<class T> inline T* Foam::UPtrList<T>::set(const label i, T* ptr) { diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index ca74393cabf072546df4a9861b231a3f7cb4170e..684ceb979e34419053fc8b3eb51b4f3eabf8f91a 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -189,11 +189,21 @@ public: return IDLList<ParticleType>::begin(); }; + const const_iterator cbegin() const + { + return IDLList<ParticleType>::cbegin(); + }; + const const_iterator end() const { return IDLList<ParticleType>::end(); }; + const const_iterator cend() const + { + return IDLList<ParticleType>::cend(); + }; + iterator begin() { return IDLList<ParticleType>::begin(); diff --git a/src/meshTools/edgeFaceCirculator/edgeFaceCirculator.H b/src/meshTools/edgeFaceCirculator/edgeFaceCirculator.H index a2a5ec7abe7f2bc0cf1f664d542e1f2aa74481c1..644b0e84a05a4caa1cf3c8df13d20063acac6422 100644 --- a/src/meshTools/edgeFaceCirculator/edgeFaceCirculator.H +++ b/src/meshTools/edgeFaceCirculator/edgeFaceCirculator.H @@ -192,9 +192,11 @@ public: // the current face. For boundary edges this is the first boundary face // reached from walking back (i.e. in opposite direction to ++) inline edgeFaceCirculator begin() const; + inline edgeFaceCirculator cbegin() const; //- iterator set to beyond the end of the walk. inline const edgeFaceCirculator& end() const; + inline const edgeFaceCirculator& cend() const; }; diff --git a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H index 558d0c75261de38c5afb13f6c56e61e0e81d19fe..d8511c4fb67c065c9e9444a1a4cb615fd1add27e 100644 --- a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H +++ b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H @@ -419,10 +419,34 @@ Foam::edgeFaceCirculator Foam::edgeFaceCirculator::begin() const } +Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cbegin() const +{ + edgeFaceCirculator iter + ( + mesh_, + faceLabel_, + ownerSide_, + index_, + isBoundaryEdge_ + ); + + if (isBoundaryEdge_) + { + iter.setCanonical(); + } + return iter; +} + + const Foam::edgeFaceCirculator& Foam::edgeFaceCirculator::end() const { return endConstIter; } +const Foam::edgeFaceCirculator& Foam::edgeFaceCirculator::cend() const +{ + return endConstIter; +} + // ************************************************************************* // diff --git a/src/meshTools/octree/octree.C b/src/meshTools/octree/octree.C index 554af3ad5abc41e23063436cf00a521a9ca276c6..fa180fd9c12baebe4080a60d2eb6d846a7c6c48e 100644 --- a/src/meshTools/octree/octree.C +++ b/src/meshTools/octree/octree.C @@ -879,6 +879,14 @@ Foam::octree<Type>::begin() const } +template <class Type> +typename Foam::octree<Type>::const_iterator +Foam::octree<Type>::cbegin() const +{ + return const_iterator(*this, 0); +} + + template <class Type> const typename Foam::octree<Type>::const_iterator& Foam::octree<Type>::end() const @@ -887,6 +895,14 @@ Foam::octree<Type>::end() const } +template <class Type> +const typename Foam::octree<Type>::const_iterator& +Foam::octree<Type>::cend() const +{ + return octree<Type>::endConstIter_; +} + + // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // template <class Type> diff --git a/src/meshTools/octree/octree.H b/src/meshTools/octree/octree.H index 33c62def017bb595d9c7d876ff76070f4d8b6f5c..8f7972324228c532cef97039661a8a4189098b51 100644 --- a/src/meshTools/octree/octree.H +++ b/src/meshTools/octree/octree.H @@ -445,10 +445,6 @@ public: //- Construct for a given octree and index const_iterator(const octree&, label); - // Member functions - - const_iterator begin() const; - // Member operators void operator=(const const_iterator&); @@ -465,9 +461,11 @@ public: //- const_iterator set to the begining of the octree inline const_iterator begin() const; + inline const_iterator cbegin() const; //- const_iterator set to beyond the end of the octree inline const const_iterator& end() const; + inline const const_iterator& cend() const; // IOstream Operators diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H index a2fb0c7d1f250e7d55c370b6185da8303010033c..bd692647abe38ab333e254acd05b12101c032f75 100644 --- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H +++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H @@ -102,6 +102,9 @@ private: // Private member functions + //- Disable resize with value + void resize(const label, const Face&); + //- Disable setSize with value void setSize(const label, const Face&);