UList::swap: implemented fast version which swaps the size and storage pointer
This commit is contained in:
parent
f3868f2114
commit
8e7c777ec5
1 changed files with 2 additions and 16 deletions
|
|
@ -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_);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue