mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 23:50:31 +03:00
Use member syntax for swapAt to give the range a chance to intercept it
This commit is contained in:
parent
c12573a337
commit
96ece512a2
1 changed files with 3 additions and 3 deletions
|
@ -1276,7 +1276,7 @@ package(std) template HeapOps(alias less, Range)
|
||||||
// Sort
|
// Sort
|
||||||
for (size_t i = r.length - 1; i > 0; --i)
|
for (size_t i = r.length - 1; i > 0; --i)
|
||||||
{
|
{
|
||||||
swapAt(r, 0, i);
|
r.swapAt(0, i);
|
||||||
siftDown(r, 0, i);
|
siftDown(r, 0, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1332,7 +1332,7 @@ package(std) template HeapOps(alias less, Range)
|
||||||
auto child1 = child + 1;
|
auto child1 = child + 1;
|
||||||
if (child1 < end && lessFun(r[child], r[child1])) child = child1;
|
if (child1 < end && lessFun(r[child], r[child1])) child = child1;
|
||||||
|
|
||||||
swapAt(r, parent, child);
|
r.swapAt(parent, child);
|
||||||
parent = child;
|
parent = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1344,7 +1344,7 @@ package(std) template HeapOps(alias less, Range)
|
||||||
parent = (child - 1) / 2;
|
parent = (child - 1) / 2;
|
||||||
if(lessFun(r[parent], r[child]))
|
if(lessFun(r[parent], r[child]))
|
||||||
{
|
{
|
||||||
swapAt(r, parent, child);
|
r.swapAt(parent, child);
|
||||||
child = parent;
|
child = parent;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue