Skip to content

Commit e38d558

Browse files
xperiandriclaude
andcommitted
fixup! docs: SortedSet in the changelog and the collection table
The changelog lists the new functions of `SortedSet` and says what a user of the BCL type or of 1.0.0 does differently: - Added: `addRange`, `removeRange`, `ofReadOnlySpan`, `ofSpan`, `build` and `update`, with a bullet for each group. The bullet of `forComparer` names the BCL members that the struct replaces, the rule of `WithComparer` for the same comparer instance, and the default value of the struct, which is the `null` comparer of the BCL. Further bullets cover `add` and `remove`, the builder, the mutating interface members, `minElement`, `maxElement`, `rev`, `item`, `indexOf` and `ItemRef`. - Changed: `forComparer Comparer<'T>.Default` restores the order of 1.0.0. `difference values set` is `removeRange values set`, and `union set values` is `addRange values set`. The BCL members that take a sequence map to `addRange`, `removeRange`, `Seq.exists`, `Seq.forall` or `ofSeq`. The element that stays follows the BCL, and the compiled name of the module is `SortedSet`. - Removed: `pick`, `tryPick` and `vTryPick` are replaced by `Seq.pick` and `Seq.tryPick`, and the replacements of `ofComparer`, `ofSeqWithComparer`, `builderWithComparer` and `builderWith` are named. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 8060588 commit e38d558

1 file changed

Lines changed: 56 additions & 14 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7272
* `hashSet { }` builds a hash set, and `HashSetCE` created with an equality comparer builds hash sets that compare with it;
7373
a `null` comparer throws `ArgumentNullException`.
7474
* `SortedSet` has every function of the FSharp.Core `Set` module, with its semantics, argument order and exceptions, plus
75-
`builder`, `choose`, `clear`, `comparer`, `forComparer`, `indexOf`, `item`, `ofBuilder`, `overlaps`, `rev`, `setEquals`,
76-
`symmetricDifference`, `toBuilder`, `tryGetValue` and `tryItem`.
77-
* `SortedSet.forComparer comparer` creates the `CustomComparerSortedSet` struct, whose members `empty`, `ofArray`,
78-
`ofList`, `ofSeq`, `singleton` and `builder` create sorted sets and builders that order their elements with the
79-
comparer, as in `(SortedSet.forComparer StringComparer.OrdinalIgnoreCase).ofSeq names`. `ofSeq` also gives an existing
80-
sorted set the comparer, and returns it when it has the comparer already. A `null` comparer throws
81-
`ArgumentNullException`. The element type needs no F# comparison; the default value of the struct orders with
82-
`Comparer<'T>.Default`, as the BCL does for a `null` comparer.
75+
`addRange`, `build`, `builder`, `choose`, `clear`, `comparer`, `forComparer`, `indexOf`, `item`, `ofBuilder`,
76+
`ofReadOnlySpan`, `ofSpan`, `overlaps`, `removeRange`, `rev`, `setEquals`, `symmetricDifference`, `toBuilder`,
77+
`tryGetValue`, `tryItem` and `update`.
78+
* `SortedSet.addRange elements set` and `removeRange elements set` take the place of the `Union` and `Except` members that
79+
take a sequence. The result keeps the comparer of the sorted set, and the input itself comes back when nothing changes.
80+
`removeRange` wraps `Except`. `addRange` adds the elements one by one, so an element of the sequence that the comparer
81+
finds equal to an element of the sorted set never replaces it, and of several equal elements of the sequence the first
82+
is added. `Union` does not promise that: when the sequence is large against the sorted set, it refills the tree from an
83+
unstable sort and can keep an element of the sequence instead.
84+
* `SortedSet.ofReadOnlySpan` and `ofSpan` create a sorted set from a span and keep the first of the elements that the
85+
comparer finds equal, where `ImmutableSortedSet.Create` with a span keeps an arbitrary one of them. `build` fills a
86+
builder with an action, and `update` applies an action to a builder of a sorted set and returns its contents, so that
87+
the in-place operations of the builder, such as `IntersectWith`, are one expression.
88+
* `SortedSet.forComparer comparer` creates the `CustomComparerSortedSet` struct, whose members `build`, `builder`, `empty`,
89+
`ofArray`, `ofList`, `ofReadOnlySpan`, `ofSeq`, `ofSpan` and `singleton` create sorted sets and builders that order
90+
their elements with the comparer, as in `(SortedSet.forComparer StringComparer.OrdinalIgnoreCase).ofSeq names`. They
91+
replace the BCL members `Create(comparer, ...)`, `CreateRange(comparer, items)`, `ToImmutableSortedSet(items, comparer)`
92+
and `CreateBuilder(comparer)`. `ofSeq` also gives an existing sorted set the comparer, as `WithComparer` does: the
93+
sorted set itself comes back for the same comparer instance, and an equal but distinct instance rebuilds it, keeping the
94+
first of the elements that the comparer finds equal. A `null` comparer throws `ArgumentNullException`.
95+
The element type needs no F# comparison. The default value of the struct orders with `Comparer<'T>.Default`, as the BCL
96+
does for a `null` comparer, so `WithComparer(null)` is `ofSeq` of the default value, where `SortedSet.ofSeq set` orders
97+
with F# generic comparison.
98+
* `SortedSet.add` and `remove` return the input itself when nothing changes, so a reference comparison of the input and
99+
the result tells whether `Add` changed anything, as the `bool` result of `Builder.Add` does. Sorted sets have no builder
100+
module: `builder`, `toBuilder` and `ofBuilder` are `CreateBuilder`, `ToBuilder` and `ToImmutable`, and the builder is
101+
used directly. The mutating members of the BCL interfaces, such as `ISet<T>.UnionWith` and `ICollection<T>.Add`, throw
102+
`NotSupportedException` on a sorted set and have no function.
103+
* `SortedSet.minElement` and `maxElement` take the place of the properties `Min` and `Max`: they read the first and the
104+
last element in O(log n) and throw `ArgumentException` for an empty sorted set, as `Set.minElement` and
105+
`Set.maxElement` do, where the properties return `default`. `tryItem 0` and `tryItem (count - 1)` return a `voption`
106+
instead. `rev` is `Reverse`, `item` is the indexer and throws `ArgumentOutOfRangeException` like it, and `indexOf` is
107+
`IndexOf`, with the bitwise complement for a missing element. `ItemRef` has no function, because a curried function
108+
cannot return a `byref`.
83109
* The `FSharp.Collections.Immutable.Option.SortedSet` and `FSharp.Collections.Immutable.Tuple.SortedSet` modules repeat
84110
`choose`, `tryGetValue` and `tryItem` with options, and `partition` and `partitionWith` with reference tuples.
85111
* `sortedSet { }` builds a sorted set, and `SortedSetCE` created with a comparer builds sorted sets that order their
@@ -102,10 +128,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
102128
`partitionWith` compare with F# generic comparison, as `Set` does, instead of `Comparer<'T>.Default`. A sorted set
103129
enumerates its elements in the order of the F# set of the same elements: strings, and tuples and other values that
104130
contain strings, compare ordinally instead of in the order of the current culture.
105-
* `SortedSet`: `difference set1 set2` returns the elements of `set1` that are not in `set2`, as `Set.difference` does; it
106-
took its arguments in the reverse order before.
131+
`SortedSet.forComparer Comparer<'T>.Default` restores the order of 1.0.0.
132+
* `SortedSet`: `difference set1 set2` returns the elements of `set1` that are not in `set2`, as `Set.difference` does. In
133+
1.0.0 `difference values set` removed a sequence from a sorted set: that is `removeRange values set` now, with the same
134+
order of the arguments. `union set values` of 1.0.0 is `addRange values set`.
135+
* `SortedSet`: `union`, `intersect`, `isSubset`, `isProperSubset`, `isSuperset` and `isProperSuperset` took a sequence as
136+
the second argument in 1.0.0 and take a sorted set now, as the `Set` functions do: pass `SortedSet.ofSeq elements`, or
137+
`(SortedSet.forComparer (SortedSet.comparer set)).ofSeq elements` to give the elements the comparer of the first
138+
sorted set. The BCL members that take a sequence map the same way: `Union` and `Except` are `addRange` and
139+
`removeRange`, `Overlaps` and `IsSupersetOf` are `Seq.exists` and `Seq.forall` with `contains`, and the others take
140+
`ofSeq` of the sequence.
141+
* `SortedSet`: the element that stays when the comparer finds two elements equal follows the BCL: `addRange` keeps the
142+
element of the sorted set, `union` keeps the element of the first sorted set, or of the larger one when both have the
143+
same comparer, `intersect` keeps the elements of the second one, and the creation functions keep the first element of
144+
their input.
107145
* `SortedSet`: `isProperSuperset set1 set2` counts the elements of `set2` that the comparer of `set1` finds equal once, as
108146
the documentation of `ImmutableSortedSet.IsProperSupersetOf` says; it counted each of them before.
147+
* `SortedSet`: the compiled name of the module is `SortedSet`, which C# callers see; it was `ImmutableSortedSetModule`.
109148
* `SortedSet`: `length` is renamed to `count` and `keyComparer` to `comparer`.
110149
* `SortedSet`: `filter`, `partition` and the set algebra keep the comparer of their input, the set algebra that of the
111150
first set. `filter` dropped the comparer before.
@@ -135,10 +174,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
135174
* The `ISet<'T>` abbreviation of `IImmutableSet<'T>`, because it shadowed `System.Collections.Generic.ISet<'T>`: use
136175
`IImmutableSet<'T>` and the `ISet` module.
137176
* The `SortedSetBuilder<'T>` abbreviation: use `SortedSet<'T>.Builder`.
138-
* `SortedSet.where`: use `filter`. `SortedSet.pick`, `tryPick` and `vTryPick`: use `Seq.pick` and `Seq.tryPick`. The
139-
public `SortedSet.check`.
140-
* `SortedSet.ofComparer`, `ofSeqWithComparer`, `builderWithComparer` and `builderWith`, which took a comparer despite its
141-
name: use the members `empty`, `ofSeq` and `builder` of `SortedSet.forComparer comparer`.
177+
* `SortedSet.where`: use `filter`. `SortedSet.pick`, `tryPick` and `vTryPick`, which the FSharp.Core `Set` module does not
178+
have: use `SortedSet.toSeq set |> Seq.pick chooser`, or `Seq.tryPick` and `ValueOption.ofOption`. The public
179+
`SortedSet.check`.
180+
* `SortedSet.ofComparer comparer`, `ofSeqWithComparer comparer elements` and `builderWithComparer comparer`: use
181+
`(SortedSet.forComparer comparer).empty`, `(SortedSet.forComparer comparer).ofSeq elements` and
182+
`(SortedSet.forComparer comparer).builder ()`. `SortedSet.builderWith`, whose argument bound to the comparer overload of
183+
the BCL member, has no replacement: sorted sets have no capacity.
142184

143185
## [1.0.0] - 2020-02-23
144186

0 commit comments

Comments
 (0)