You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ All notable changes to Celerity are documented here. This project follows [Keep
27
27
28
28
### Fixed
29
29
30
+
-`PartialSort.TopK` now throws `ArgumentException` when its `destination` overlaps its `source`, instead of silently returning a wrong answer and writing to the source it documents as untouched. Disjoint slices of one array are still accepted, matching `RadixSort` and `CountingSort`.
30
31
- Eight documentation links pointed at anchors that do not exist: seven `CeleritySet` / `SwissSet` references in `docs/api/collections.md` and one in `CHANGELOG.md`. GitHub deletes `<`, `>` and `,` from a heading without substituting a separator, so `CeleritySet<T, THasher>` anchors as `#celeritysett-thasher`, not the `#celerityset-t-thasher` everyone writes. Closes [#339](https://github.com/marius-bughiu/Celerity/issues/339).
Copy file name to clipboardExpand all lines: docs/api/sorting.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,6 +182,8 @@ struct hashers follow. Nulls sort first under the natural order, matching `Compa
182
182
|`TopK<T, TComparer>(ReadOnlySpan<T> source, Span<T> destination, TComparer comparer)`| The same under a custom order — pass a reversing comparer to take the *smallest*. |
183
183
184
184
**Exceptions.**`ArgumentOutOfRangeException` when `count` is negative or greater than `keys.Length`.
185
+
`ArgumentException` when a `TopK``destination` shares storage with its `source`. As everywhere else
186
+
in the package, only genuine overlap is rejected — two disjoint slices of one array are fine.
185
187
186
188
**Properties worth relying on.**
187
189
@@ -195,7 +197,8 @@ struct hashers follow. Nulls sort first under the natural order, matching `Compa
195
197
an `IComparer<T>`-typed helper and so boxes a `struct` comparer on every call. If you want
196
198
introsort's constant factor over a whole span, call the BCL directly.
197
199
-**Not stable**, in any form.
198
-
-**`TopK` never writes to `source`** and allocates nothing — the destination *is* the heap.
200
+
-**`TopK` never writes to `source`** and allocates nothing — the destination *is* the heap, which
201
+
is why a `destination` overlapping `source` is rejected rather than silently answered wrongly.
0 commit comments