diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index 04eb911825..c913892c26 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -26,7 +26,7 @@ Class Foam::DynamicList Description - A 1D vector of objects of type \ which resizes itself as necessary to + A 1D vector of objects of type \ that resizes itself as necessary to accept the new objects. Internal storage is a compact array and the list can be shrunk to compact @@ -149,7 +149,7 @@ public: //- Append an element at the end of the list inline void append(const T& e); - //- Return and remove the top element + //- Remove and return the top element inline T remove(); //- Return non-const access to an element, diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index 6da8a20678..d383480035 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -120,7 +120,6 @@ inline void Foam::DynamicList::clear() template inline void Foam::DynamicList::clearStorage() { - List::size() = allocSize_; // make List consistent List::clear(); allocSize_ = 0; } @@ -167,7 +166,6 @@ Foam::DynamicList::transfer { allocSize_ = l.allocSize(); List::transfer(l); // take over storage - l.allocSize_ = 0; } @@ -202,7 +200,7 @@ inline T Foam::DynamicList::remove() { FatalErrorIn ( - "void Foam::DynamicList::remove()" + "Foam::DynamicList::remove()" ) << "List is empty" << abort(FatalError); } @@ -267,7 +265,10 @@ inline void Foam::DynamicList::operator= ) { List::operator=(l); - allocSize_ = l.allocSize(); + // allocSize_ = l.allocSize(); // wrong + allocSize_ = List::size(); + // ^^^^ with this change, we could just use + // DynamicList::operator=(const List&) instead } diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 21cc042050..a599490781 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -38,14 +38,11 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // // Construct with length specified template -List::List(const label s) +Foam::List::List(const label s) : UList(NULL, s) { @@ -69,7 +66,7 @@ List::List(const label s) // Construct with length and single value specified template -List::List(const label s, const T& a) +Foam::List::List(const label s, const T& a) : UList(NULL, s) { @@ -98,7 +95,7 @@ List::List(const label s, const T& a) // Construct as copy template -List::List(const List& a) +Foam::List::List(const List& a) : UList(NULL, a.size_) { @@ -130,7 +127,7 @@ List::List(const List& a) // Construct as copy or re-use as specified. template -List::List(List& a, bool reUse) +Foam::List::List(List& a, bool reUse) : UList(NULL, a.size_) { @@ -166,10 +163,10 @@ List::List(List& a, bool reUse) } -// Construct given size and start and end iterators. +// Construct given start and end iterators. template template -List::List(InputIterator first, InputIterator last) +Foam::List::List(InputIterator first, InputIterator last) { label s = 0; for @@ -200,8 +197,8 @@ List::List(InputIterator first, InputIterator last) // Construct as copy of FixedList template -template