Commit graph

948 commits

Author SHA1 Message Date
Walter Bright
a51c0eada6
co-locate overloads of std.algorithm.mutation.swap() (#8951) 2024-10-18 13:18:04 +08:00
Jonathan M Davis
913ef46bca
Fix bugzilla issue 24809: In some cases, stable sort assigns to unininitialized elements (#9057) 2024-10-17 20:00:02 -07:00
Sönke Ludwig
2168becf74 Fix Bugzilla 24773: Don't invoke destructors on uninitialized elements in stable sort
Uses a regular initialized temporary array when sorting elements with an elaborate assignment to avoid undefined behavior when destructors, postblits or copy constructors are invoked during the array assignment.
2024-09-20 13:38:31 +02:00
Nick Treleaven
9ffe71fea3
Fix Bugzilla 15315 - can break immutable with std.algorithm.move (#9032) 2024-07-29 06:49:54 +08:00
0-v-0
d8e8f1f351 Remove std.conv import from quickSortImpl 2024-06-22 11:07:40 +08:00
FeepingCreature
539dc473ba
Fix bugzilla issue 24596: std.typecons.Rebindable2: Don't destroy classes! Only destroy structs! (#9012) 2024-06-10 23:10:18 +08:00
dokutoku
9a8325ca5f
Fix some invalid links (#8994)
Co-authored-by: dokutoku <3729541-dokutoku@users.noreply.gitlab.com>
2024-04-29 22:08:10 +08:00
Nick Treleaven
0b45fc77c6 Fix pred description when there's no needle 2024-03-13 11:26:58 +00:00
Nick Treleaven
4ea7dd3e07 Add short descriptions for each overload set; minor tweaks
Short descriptions improve ddox output.
Use overload instead of version.
2024-03-13 11:26:50 +00:00
Nick Treleaven
e695747422 Update cheat sheet description 2024-03-13 11:19:06 +00:00
Nick Treleaven
ac6c03a646 [std.algorithm.searching] Improve count docs
Fix `value` missing reference.
Tweak wording.
Explain `pred` better.
Separate out needle overloads from the other 2.
Fix 'Returns'.
Split example into 2.
2024-03-08 16:10:59 +00:00
Paul Backus
54a4afae9c
Merge pull request #8912 from ntrel/mut-remove
[std.algorithm.mutation] Improve `remove` docs
2024-02-15 08:59:06 -05:00
Walter Bright
42b8c65ccf CheckBy postblit should be scope 2024-02-12 09:24:07 +01:00
Nick Treleaven
ca9561b389 [std.algorithm.mutation] Improve remove docs
Make examples runnable.
Add 2 subheadings.
Minor tweaks.
Fix throwing example of tuple offset.
2024-02-10 12:34:45 +00:00
Mathis Beer
5976fe8c1a Fix Bugzilla issue 24342: Actually check that range and sentinel types match in until before using "sentinel as subrange" mode.
`until` does special magic when `Sentinel` consists of multiple elements of `Range`. However, because `Range` can be a range of ranges, in which case even a `Sentinel` that is a range may still only be a single element, we must confirm that the element type of `Sentinel` is actually the same as `Range` before enabling this.
The `immutable ElementEncodingType` idiom is stolen from `startsWith`, which forms the basis of `until` anyways (see `predSatisfied`).
2024-01-18 14:56:52 +08:00
Dennis
8c39523ba9
Merge pull request #8857 from ntrel/find-split-result
[std.algorithm.searching] Refactor `findSplit` result types
2023-11-28 23:38:54 +01:00
Dennis
505f81ab87
Merge pull request #8856 from ntrel/find-split-docs
[std/algorithm/searching] Improve findSplit docs
2023-11-28 23:34:43 +01:00
Nick Treleaven
52ae4d36a9 3 minor tweaks 2023-11-28 17:38:29 +00:00
Nick Treleaven
0819fec814 [std.algorithm.searching] Refactor findSplit result types 2023-11-28 17:28:55 +00:00
Nick Treleaven
6b5f730b84 [std/algorithm/searching] Improve findSplit docs
Improve formatting for returned tuple.
Fix type of `result[1]` for After/Before.
Fix `pred` description.
Show example using custom `pred`.
2023-11-27 17:19:31 +00:00
Dennis
fe33c84610
Merge pull request #8836 from ntrel/fold-docs
[std.algorithm] Improve `fold` docs
2023-11-20 17:36:06 +01:00
Nick Treleaven
0ced94ca1c
[std.algorithm] Split find docs into 2 (#8844)
It's much clearer to have separate docs for the overload not taking
`needle`, because its `pred` has a different signature and its behaviour
is simpler. It was necessary to move that overload (and its unittests)
above the other two.

Also improve the docs for the other overloads:
Remove duplicate BIGOH sentence already present under *Complexity*.
Use `e, n` for predicate parameter names, short for `element, needle`.
2023-11-20 22:19:03 +08:00
Nick Treleaven
edc5bbde7b Make new tests documented 2023-11-20 11:11:44 +00:00
Nick Treleaven
a2c2f79dfa Fix Issue 11111 - std.algorithm.canFind should support Needles...
The requirement that each needle must be a range is arbitrary, so remove
it.
Note: This overload of `canFind` calls `find(haystack, needles)` which
calls `startsWith`, which accepts mixed element and range needles.
2023-11-20 10:58:16 +00:00
Nick Treleaven
585ddbe691
[std.algorithm] Improve canFind docs (#8843)
Minor tweaks.
Fix wrong `LREF`.
Also fix wrong `REF` to `among`.
2023-11-20 05:55:26 +08:00
Nick Treleaven
7f06f2358a Rename b to e for element in predicates 2023-10-31 17:40:45 +00:00
Nick Treleaven
2170bb37bc Tweak seed description 2023-10-31 17:37:05 +00:00
Nick Treleaven
5762f3311b Explain predicate signature 2023-10-31 17:26:48 +00:00
Nick Treleaven
f491d1f233 [std.algorithm] Improve fold docs
Mention iteratively calling predicates in summary.
Use list to explain calling a single predicate with a seed.
Mention multiple results are produced in description.
Use list for see also.
Rename `seed` parameter `seeds` and fix docs.
Fix result docs when >1 predicate.
2023-10-30 16:17:24 +00:00
Per Nordlöw
578dfbfeb3 Correct spelling of Seperator to Separator in joiner() 2023-10-10 15:58:42 +02:00
Iain Buclaw
faca94c214 Fix broken tests caused by merge conflicts 2023-07-15 14:15:20 +00:00
Iain Buclaw
ab307c9acf Merge remote-tracking branch 'upstream/stable' into merge_stable 2023-07-15 13:49:21 +00:00
FeepingCreature
dfcbee7056 Fix issue 24027: Instead of a bunch of special-cases, just check that Rebindable did in fact alias itself away.
This looks ugly, but it's just for the `stable` branch - this is fixed on `master` via the `Rebindable2` rewrite https://github.com/dlang/phobos/pull/8768
2023-07-04 01:31:32 +02:00
Iain Buclaw
a3526d11dd Merge remote-tracking branch 'upstream/stable' into merge_stable 2023-07-02 02:10:20 +00:00
Mathis Beer
10601cc046 Add std.typecons.Rebindable2 for internal use.
Rebindable2 is a simplified version of std.typecons.Rebindable that clears up every special case: classes, arrays and structs now have the same struct.
Whichever type you instantiate `Rebindable2` with, you always get the same type out by calling `value.get` on the resulting container.
Also use this type to simplify the parts of Phobos we previously used `Rebindable` for.
2023-06-19 13:24:30 +02:00
Dennis
5cd77a6e32
User hyperlinks to refer to bugzilla issues (#8766) 2023-06-16 14:45:44 +03:00
FeepingCreature
f715941036 Fix issue 23993: Discard Rebindable before passing extremum to comparator. 2023-06-15 19:06:27 +02:00
Robert burner Schadek
e1f7edae57 Better std.algorithm.iteration.permutations error messages 2023-05-26 05:45:32 +02:00
Mathis Beer
2f6b2efaf7 Change struct Rebindable to just use cast() if this is sufficient.
This works better at compiletime.
2023-04-19 22:59:43 +00:00
Mathis Beer
b818901e63 Fix issue 22786 (immutable element in maxElement) by always using Rebindable. 2023-04-19 22:59:43 +00:00
FeepingCreature
656ae7905e
Fix issue 22785: joiner should Unqual child ranges. (#8737)
* Fix issue 22785: `joiner` should `Unqual` child ranges.
This allows use with `immutable T[][]` and similar.

---------

Co-authored-by: Petar Kirov <petar.p.kirov@gmail.com>
2023-04-20 01:59:19 +03:00
Nick Treleaven
01a12f919e
[std.algorithm.searching] Don't instantiate template pred in all and any constraints (#8715)
Fixes Issue 23769 - Lambda isn't a unary predicate for lambda that
doesn't compile.
2023-04-10 19:10:18 +03:00
Nick Treleaven
72da991685
[std.algorithm.searching] Fix 2 typos in docs (#8728) 2023-03-31 15:38:47 +03:00
Robert burner Schadek
d8c627e037 Better std.algorithm.comparison.clamp error messages 2023-03-15 16:53:20 +01:00
Robert burner Schadek
8546da5b04 Better std.algorithm.iteration.filter error messages 2023-02-21 10:17:22 +01:00
Ikey Doherty
ac8318c5ad
algorithm/sorting: Fix typo introduced in PR #8678
Typo specifically introduced in:

 - baaa1117de

Signed-off-by: Ikey Doherty <ikey@serpentos.com>
2023-02-18 14:33:49 +00:00
Robert burner Schadek
ef2eb4fdb7 Better Sort static assert error messages 2023-02-13 21:14:34 +01:00
Iain Buclaw
6d7b83d49c Merge remote-tracking branch 'upstream/stable' into merge_stable 2023-02-13 01:30:01 +00:00
Mathis Beer
c06e3171f1 Fix issue 23668: TimSort must avoid default initialization if the type being sorted has it disabled. 2023-02-04 09:51:27 +01:00
DanutAldea
cce4c938dd Fix Issue 20397 2023-02-01 00:44:25 +01:00