mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 15:40:36 +03:00
[trivial] Tweak docs for std.algorithm.sort
This commit is contained in:
parent
6cbaa94251
commit
46a08e86d7
1 changed files with 11 additions and 9 deletions
|
@ -1086,16 +1086,21 @@ private void optimisticInsertionSort(alias less, Range)(Range r)
|
||||||
// sort
|
// sort
|
||||||
/**
|
/**
|
||||||
Sorts a random-access range according to the predicate $(D less). Performs
|
Sorts a random-access range according to the predicate $(D less). Performs
|
||||||
$(BIGOH r.length * log(r.length)) evaluations of $(D less). Stable sorting
|
$(BIGOH r.length * log(r.length)) evaluations of $(D less). If `less` involves
|
||||||
requires $(D hasAssignableElements!Range) to be true.
|
expensive computations on the _sort key, it may be worthwhile to use
|
||||||
|
$(LREF schwartzSort) instead.
|
||||||
|
|
||||||
$(D sort) returns a $(REF SortedRange, std,range) over the original range, which
|
Stable sorting requires $(D hasAssignableElements!Range) to be true.
|
||||||
functions that can take advantage of sorted data can then use to know that the
|
|
||||||
|
$(D sort) returns a $(REF SortedRange, std,range) over the original range,
|
||||||
|
allowing functions that can take advantage of sorted data to know that the
|
||||||
range is sorted and adjust accordingly. The $(REF SortedRange, std,range) is a
|
range is sorted and adjust accordingly. The $(REF SortedRange, std,range) is a
|
||||||
wrapper around the original range, so both it and the original range are sorted,
|
wrapper around the original range, so both it and the original range are sorted.
|
||||||
but other functions won't know that the original range has been sorted, whereas
|
Other functions can't know that the original range has been sorted, but
|
||||||
they $(I can) know that $(REF SortedRange, std,range) has been sorted.
|
they $(I can) know that $(REF SortedRange, std,range) has been sorted.
|
||||||
|
|
||||||
|
Preconditions:
|
||||||
|
|
||||||
The predicate is expected to satisfy certain rules in order for $(D sort) to
|
The predicate is expected to satisfy certain rules in order for $(D sort) to
|
||||||
behave as expected - otherwise, the program may fail on certain inputs (but not
|
behave as expected - otherwise, the program may fail on certain inputs (but not
|
||||||
others) when not compiled in release mode, due to the cursory $(D assumeSorted)
|
others) when not compiled in release mode, due to the cursory $(D assumeSorted)
|
||||||
|
@ -1106,9 +1111,6 @@ always satisfy these conditions for floating point types, because the expression
|
||||||
will always be $(D false) when either $(D a) or $(D b) is NaN.
|
will always be $(D false) when either $(D a) or $(D b) is NaN.
|
||||||
Use $(REF cmp, std,math) instead.
|
Use $(REF cmp, std,math) instead.
|
||||||
|
|
||||||
If `less` involves expensive computations on the _sort key, it may be
|
|
||||||
worthwhile to use $(LREF schwartzSort) instead.
|
|
||||||
|
|
||||||
Params:
|
Params:
|
||||||
less = The predicate to sort by.
|
less = The predicate to sort by.
|
||||||
ss = The swapping strategy to use.
|
ss = The swapping strategy to use.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue