Commit graph

212 commits

Author SHA1 Message Date
Julian Fondren
ea5726f9f4 std.algorithm.sorting: fix typo and related texts 2021-09-17 04:09:34 -05:00
berni44
b2019ebab0 Narrow imports of std.math in the rest of phobos. 2021-04-21 03:00:57 +02:00
Arne
8c42ec9d8a
Check for sortedness must not use == (#7928)
Check for sortedness must not use `==`
merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
2021-04-14 17:58:11 +02:00
dkorpel
853e667034 improve documentation of std.algorithm.sorting 2021-03-03 01:05:36 +01:00
Martin Kinkelin
1a459c5996 Get rid of std.conv.emplace[Ref](), use core[.internal].lifetime
The emplace() stuff was moved to druntime; for some reason, it's still
in Phobos.

I've diffed the two versions, and they are still almost identical (incl.
unittests); the druntime version appears to have seen some improvements
(e.g., forwarding r/lvalueness of the arguments) in the meantime.
2021-01-17 16:02:25 +01:00
Martin Nowak
498b4b97d6 Merge remote-tracking branch 'upstream/master' into stable
Conflicts:
	posix.mak
2020-09-09 10:18:21 +02:00
MoonlightSentinel
255f9496d1
Fix Issue 21183 - schwartzSort does not strip const
Fixed by using the unqualified type if possible
2020-08-21 15:06:11 +02:00
MoonlightSentinel
574f1f594f
Fix issue - sort should move elements instead of copy...
... because it's reordering elements instead. Calling `opAssign` on
unitialized members might also  cause errors if the implementation
requires a valid instance (see `TimSortImpl`)
2020-06-19 09:10:58 +02:00
Hiroki Noda
4cdc906b3e [Trivial] Use std.meta instead of std.typetuple 2020-05-13 10:49:16 +09:00
Martin Nowak
a7d8def71b Merge remote-tracking branch 'upstream/stable' into merge_stable 2020-05-11 19:29:12 +02:00
Vladimir Panteleev
793a78c588
Fix Issue 20799 - schwartzSort does not pin transformation results with indirections, leading to memory corruption 2020-05-06 09:57:21 +00:00
MoonlightSentinel
54dbc0668c
Fix Issue 20751 - SortedRange with ref predicate parameters fails
isTwoWayCompatible should accept functions with ref parameters.
2020-04-26 00:44:39 +02:00
Geod24
04f3979317 Replace 'Issue XXX' with Bugzilla links
Make the links clickable, as was done in the DMD repository.
Also avoids any ambiguity w.r.t. where the issue is stored.
2020-04-13 16:28:09 +09:00
Atila Neves
85aede0639 Remove version(assert) from TimSort
If `-debug` is passed to the compiler, `version(assert)` is true.
TimSort has a `version(assert)` that checks some invariants, and uses
std.format.format for better error messages. Unfortunately, since it
is templated code, this results in Phobos template instantiations of
`format` in the user's code when `-debug` is used.

Given that default dub builds use `-debug`, this is a very common
problem.

Instead of removing the invariant checks, this changes it so they only
happen when testing Phobos itself.
2020-04-09 19:06:35 +02:00
Martin Kinkelin
5497b666e4 std.algorithm.sorting: Enable binary transform function for schwartzSort
Receiving the element's index in the original range as 2nd parameter.
2020-01-25 04:36:33 +01:00
Alexandru Militaru
bb62aaca3d Replaced version (unittest) with version (StdUnittest) to avoid unnecessary overhead when compiling with -unittest 2020-01-19 14:05:17 +02:00
Berni
58c3a75738 Fix Issue 15230 - Inconsistent std.range.SortedRange predicate checks 2019-09-29 19:39:05 +02:00
Brian Kessler
8a78157f04 std.algorithm.sorting: fix typo in pivotPartition 2019-07-21 23:22:34 -06:00
Robert Schadek
dbf9d93d95 Adds assert messages
review
2019-06-26 08:37:24 +01:00
The Dlang Bot
432556e1ca
Merge pull request #7024 from wilzbach/import-selective
Use selective top-level module imports in std.algorithm
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2019-05-23 12:07:47 +02:00
Sebastian Wilzbach
12c5e1ee91 Use selective top-level module imports in std.algorithm 2019-05-23 10:21:19 +02:00
Aurélien Fredouelle
f03f7ac189 schwartzSort: added test actually checking the ordering 2019-05-11 09:15:52 +01:00
Aurelien Fredouelle
32346c8ded Fixed Issue 13965 - More handy schwartzSort 2019-05-10 17:27:12 +01:00
H. S. Teoh
3cf78da259 [dox] Cross-reference .merge and .multiwayMerge.
These two functions are related but play two different roles:
std.algorithm.sorting.merge takes a static number of ranges of possibly
disparate types (but compatible elements), and is useful for composing
ranges at compile-time. However, it cannot take a variable number of
ranges at runtime because all ranges must be statically known.

That latter role is played std.algorithm.setops.multiwayMerge, which
takes a range of ranges to merge, and so can merge a variable number of
ranges at runtime.  However, because of that, it cannot merge ranges of
disparate types (of compatible elements), and so is unsuitable for
compile-time range composition, unless a workaround like the range class
interface is used.

The docs for these two functions really should cross-reference each
other so that users can more easily find the correct function for their
needs.
2019-02-01 00:13:15 +01:00
Robert Schadek
a05af05d95 nthPermutation (#5068)
add the function nthPermutation that permutates a given range in place n
permutations in O(1).

This is O(n - 1) steps faster than calling nextPermutation n times.
2018-11-12 19:33:28 +08:00
aG0aep6G
08f76c2974 Ddoc: fix botched backticks 2018-10-16 23:37:17 +02:00
Iain Buclaw
fd5facfe04 posix.mak: Enforce whitespace before opening parenthesis for version conditions 2018-09-22 16:57:24 +02:00
Brian Schott
1bb5636617
Fix typo. 2018-06-20 21:30:59 -07:00
Brian Schott
da9b10f859
Fix doc comment for pivotPartition
Looks like a search-and-replace messed up the code markup. Also, it seems like the range specified in the second list item was not consistent with its explanation.
2018-06-20 21:27:45 -07:00
Sebastian Wilzbach
c324714fde Remove a few cases of underscore escaping 2018-06-04 13:05:01 +02:00
Steven Schveighoffer
adaba541eb Remove version(unittest) imports to avoid extra imports in user code. 2018-04-12 15:46:56 -04:00
Sebastian Wilzbach
e9e6ca4039 std.algorithm.{searching,sorting}: prepare for -dip1000 2018-04-06 05:15:06 +02:00
Nathan Sashihara
c1d1c0e874 Issue 18715 - Non-documented unittests should not use unpredictableSeed or default Random alias 2018-04-04 18:08:00 -04:00
Sebastian Wilzbach
87301eb1b5 Merge remote-tracking branch 'upstream/stable' into merge_stable 2018-03-25 18:23:14 +02:00
Sebastian Wilzbach
e7a8110ad3 Fix Ddoc error in the quickoverview of std.algorithm.sorting 2018-03-16 11:23:29 +01:00
Jack Stouffer
5b74692bf8
Update sorting.d 2018-03-12 10:10:59 -04:00
The Dlang Bot
78f7209c4a
Merge pull request #6156 from wilzbach/fix-8341
Fix Issue 8341 - topN(zip()) doesn't work
merged-on-behalf-of: Jack Stouffer <jack@jackstouffer.com>
2018-03-12 14:07:43 +01:00
Jack Stouffer
663b5b9278 Revert addition of StdUnittest 2018-02-20 13:32:32 -05:00
Sebastian Wilzbach
ede44cbc63 Fix Issue 8341 - topN(zip()) doesn't work 2018-02-11 01:24:18 +01:00
Jack Stouffer
18cbb29b04 Replaced version(unittest) blocks with version(StdUnittest) 2018-02-01 19:56:59 -05:00
Sebastian Wilzbach
7fb3d4249f Remove references to STL 2018-01-30 16:08:20 +01:00
Sebastian Wilzbach
8227e00cd9 Manual fixup 2017-12-29 01:48:45 +01:00
Sebastian Wilzbach
fc0c29f3a2 Markdownify std.algorithm
Done with: https://github.com/wilzbach/dscanner-fix/blob/master/d_code_markdown.d
2017-12-29 01:17:40 +01:00
Johan Engelen
fd009c7434
Expand topN testcase
Passing the comparison operation as string "a < b" is tested a few lines up. This adds a test for passing a lambda function.
2017-12-15 00:18:25 +01:00
Johan Engelen
acb4c7838c
Fix intentional discarding of return value in topN
This fixes a warning one gets when compiling with warnings enabled:
"phobos/std/algorithm/sorting.d(3122): Warning: calling testcase.foo.__lambda1 without side effects discards return value of type bool, prepend a cast(void) if intentional"

Testcase that fails compilation with `-w`:
```
import std.algorithm.sorting;

auto foo() {
    int[] v = [ 25, 7, 9, 2, 0, 5, 21 ];
    return topN!((a, b) => a > b)(v, 100);
}
```
2017-12-15 00:10:49 +01:00
Sebastian Wilzbach
df6365092a Replace body keyword with its replacement: do
Automatic replacement with

    sed -i "s/^\([ ]*\)body/\1do/" -i **/*.d
2017-11-20 15:33:52 +01:00
Sebastian Wilzbach
97a2c88175 Move public unittest below their respective declaration 2017-11-20 14:17:41 +01:00
RazvanN7
3a4f83577e Get rid of unused variables in std/algorithm 2017-08-02 17:30:16 +03:00
The Dlang Bot
739c40957c Merge pull request #5151 from wilzbach/static_if_sorting
[Static if] replace overload constraints with static if (sorting.d)
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
2017-07-17 21:40:42 +02:00
Sebastian Wilzbach
e3c91711a1 Fix random coverage in std.algorithm.sorting 2017-07-07 21:40:59 +02:00