mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
UList::swap: implemented fast version which swaps the size and storage pointer
This commit is contained in:
@ -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_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user