ENH: DynamicList append() returns reference to allow chaining

This commit is contained in:
Mark Olesen
2010-09-14 11:43:50 +02:00
parent 2a37f5b11c
commit d18695d70d
2 changed files with 21 additions and 6 deletions

View File

@ -180,13 +180,22 @@ public:
// Member Operators
//- Append an element at the end of the list
inline void append(const T&);
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
(
const T&
);
//- Append a List at the end of this list
inline void append(const UList<T>&);
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
(
const UList<T>&
);
//- Append a UIndirectList at the end of this list
inline void append(const UIndirectList<T>&);
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
(
const UIndirectList<T>&
);
//- Remove and return the top element
inline T remove();

View File

@ -305,7 +305,8 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::xfer()
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
(
const T& t
)
@ -314,11 +315,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
setSize(elemI + 1);
this->operator[](elemI) = t;
return *this;
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
(
const UList<T>& lst
)
@ -339,11 +342,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
{
this->operator[](nextFree++) = lst[elemI];
}
return *this;
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
(
const UIndirectList<T>& lst
)
@ -355,6 +360,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
{
this->operator[](nextFree++) = lst[elemI];
}
return *this;
}