mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: mantis #157: swapUp/swapDown changed when considering first/last element
This commit is contained in:
@ -65,30 +65,36 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
myList.append(500.3);
|
myList.append(500.3);
|
||||||
|
myList.append(200.3);
|
||||||
myList.append(100.3);
|
myList.append(100.3);
|
||||||
|
|
||||||
|
|
||||||
Info<< nl << "And again using STL const_iterator: " << nl << endl;
|
Info<< nl << "And again using STL const_iterator: " << nl << endl;
|
||||||
|
|
||||||
const DLList<scalar>& const_myList = myList;
|
|
||||||
|
|
||||||
forAllConstIter(DLList<scalar>, const_myList, iter)
|
forAllConstIter(DLList<scalar>, myList, iter)
|
||||||
{
|
{
|
||||||
Info<< "element:" << *iter << endl;
|
Info<< "element:" << *iter << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< nl << "Testing swapUp and swapDown: " << endl;
|
||||||
|
|
||||||
|
Info<< nl << "swapUp" << endl;
|
||||||
|
|
||||||
myList.swapUp(myList.DLListBase::first());
|
myList.swapUp(myList.DLListBase::first());
|
||||||
myList.swapUp(myList.DLListBase::last());
|
myList.swapUp(myList.DLListBase::last());
|
||||||
|
|
||||||
forAllConstIter(DLList<scalar>, const_myList, iter)
|
forAllIter(DLList<scalar>, myList, iter)
|
||||||
{
|
{
|
||||||
Info<< "element:" << *iter << endl;
|
Info<< "element:" << *iter << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< nl << "swapDown" << endl;
|
||||||
|
|
||||||
myList.swapDown(myList.DLListBase::first());
|
myList.swapDown(myList.DLListBase::first());
|
||||||
myList.swapDown(myList.DLListBase::last());
|
myList.swapDown(myList.DLListBase::last());
|
||||||
|
|
||||||
forAllConstIter(DLList<scalar>, const_myList, iter)
|
forAllIter(DLList<scalar>, myList, iter)
|
||||||
{
|
{
|
||||||
Info<< "element:" << *iter << endl;
|
Info<< "element:" << *iter << endl;
|
||||||
}
|
}
|
||||||
@ -103,8 +109,8 @@ int main(int argc, char *argv[])
|
|||||||
Info<< nl << "source: " << myList << nl
|
Info<< nl << "source: " << myList << nl
|
||||||
<< nl << "target: " << newList << endl;
|
<< nl << "target: " << newList << endl;
|
||||||
|
|
||||||
|
|
||||||
Info<< nl << "Done." << endl;
|
Info<< nl << "Done." << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -94,23 +94,23 @@ bool Foam::DLListBase::swapUp(DLListBase::link* a)
|
|||||||
if (ap == first_)
|
if (ap == first_)
|
||||||
{
|
{
|
||||||
first_ = a;
|
first_ = a;
|
||||||
|
ap->prev_ = a;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ap->prev_->next_ = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == last_)
|
if (a == last_)
|
||||||
{
|
{
|
||||||
last_ = ap;
|
last_ = ap;
|
||||||
|
a->next_ = ap;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (a->next_)
|
|
||||||
{
|
{
|
||||||
a->next_->prev_ = ap;
|
a->next_->prev_ = ap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ap->prev_)
|
|
||||||
{
|
|
||||||
ap->prev_->next_ = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
a->prev_ = ap->prev_;
|
a->prev_ = ap->prev_;
|
||||||
ap->prev_ = a;
|
ap->prev_ = a;
|
||||||
|
|
||||||
@ -135,19 +135,19 @@ bool Foam::DLListBase::swapDown(DLListBase::link* a)
|
|||||||
if (a == first_)
|
if (a == first_)
|
||||||
{
|
{
|
||||||
first_ = an;
|
first_ = an;
|
||||||
|
a->prev_ = an;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a->prev_->next_ = an;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (an == last_)
|
if (an == last_)
|
||||||
{
|
{
|
||||||
last_ = a;
|
last_ = a;
|
||||||
|
an->next_ = a;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (a->prev_)
|
|
||||||
{
|
|
||||||
a->prev_->next_ = an;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (an->next_)
|
|
||||||
{
|
{
|
||||||
an->next_->prev_ = a;
|
an->next_->prev_ = a;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user