Commit 82241e64 authored by Henry Weller's avatar Henry Weller
Browse files

UList::swap: implemented fast version which swaps the size and storage pointer

parent 4cd1e853
......@@ -81,22 +81,8 @@ void Foam::UList<T>::operator=(const T& t)
template<class T>
void Foam::UList<T>::swap(UList<T>& a)
{
if (a.size_ != this->size_)
{
FatalErrorIn("UList<T>::swap(const UList<T>&)")
<< "ULists have different sizes: "
<< this->size_ << " " << a.size_
<< abort(FatalError);
}
List_ACCESS(T, (*this), vp);
List_ACCESS(T, a, ap);
T tmp;
List_FOR_ALL((*this), i)
tmp = List_CELEM((*this), vp, i);
List_ELEM((*this), vp, i) = List_CELEM(a, ap, i);
List_ELEM(a, ap, i) = tmp;
List_END_FOR_ALL
Swap(size_, a.size_);
Swap(v_, a.v_);
}
......
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