mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
Clean up getPivot() a little.
This commit is contained in:
parent
0a40daaead
commit
174b705bd5
1 changed files with 5 additions and 1 deletions
|
@ -6285,6 +6285,10 @@ unittest
|
|||
/*private*/
|
||||
size_t getPivot(alias less, Range)(Range r)
|
||||
{
|
||||
// This algorithm sorts the first, middle and last elements of r,
|
||||
// then returns the index of the middle element. In effect, it uses the
|
||||
// median-of-three heuristic.
|
||||
|
||||
alias binaryFun!(less) pred;
|
||||
immutable len = r.length;
|
||||
immutable size_t mid = len / 2;
|
||||
|
@ -6316,7 +6320,7 @@ size_t getPivot(alias less, Range)(Range r)
|
|||
assert(0);
|
||||
}
|
||||
|
||||
return len / 2;
|
||||
return mid;
|
||||
}
|
||||
|
||||
// @@@BUG1904
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue