Commit 1df60791 authored by Henry Weller's avatar Henry Weller
Browse files

DynamicList: Added initialized constructor and STL erase function

parent 89869371
......@@ -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
......
......@@ -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;
}
// ************************************************************************* //
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment