diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index 893804bb322c0d556850f0e9150ffa60fe516799..f62ba3a41a97a38d19626b466be67e18f67f1934 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -104,6 +104,9 @@ public: //- Construct given size. explicit inline DynamicList(const label); + //- Construct with given size and value for all elements. + inline DynamicList(const label, const T&); + //- Construct copy. inline DynamicList(const DynamicList<T, SizeInc, SizeMult, SizeDiv>&); @@ -224,6 +227,12 @@ public: inline void operator=(const UIndirectList<T>&); + // STL member functions + + //- Erase an element, move the remaining elements to fill the gap + // and resize the List + typename UList<T>::iterator erase(typename UList<T>::iterator); + // IOstream operators diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index d62f00006c19b3e8230dacb3daf6b5472cde1c7a..fdd4ec571a8030dfdc4f56c1f76b4e3161b29445 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -49,6 +49,18 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList } +template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList +( + const label nElem, + const T& a +) +: + List<T>(nElem, a), + capacity_(nElem) +{} + + template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList ( @@ -483,4 +495,32 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator= } +// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * // + +template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> +typename Foam::UList<T>::iterator +Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::erase +( + typename UList<T>::iterator curIter +) +{ + typename Foam::UList<T>::iterator iter = curIter; + typename Foam::UList<T>::iterator nextIter = curIter; + + if (iter != this->end()) + { + ++iter; + + while (iter != this->end()) + { + *nextIter++ = *iter++; + } + + this->setSize(this->size() - 1); + } + + return curIter; +} + + // ************************************************************************* //