Skip to content

Commit 5620b46

Browse files
xperiandriclaude
andcommitted
fixup! docs: HashSet and ISet in the changelog and the collection table
The changelog lists the new `addRange`, `removeRange`, `ofReadOnlySpan`, `ofSpan`, `build` and `update` of `HashSet`, the members of `CustomComparerHashSet`, and `addRange` and `removeRange` of `ISet`. It says what a user of the BCL type or of 1.0.0 does differently: `difference values set` is `removeRange values set`, `union set values` is `addRange values set`, the set algebra and the predicates take a hash set instead of a sequence, the exact replacements of `ofComparer`, `ofSeqWithComparer`, `builderWithComparer` and `builderWith`, the replacement of `pick`, `tryPick` and `vTryPick`, `WithComparer`, which element stays when the comparer finds two equal, the count of `isProperSuperset`, and the compiled name of the module. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 41308a1 commit 5620b46

1 file changed

Lines changed: 43 additions & 12 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
value, as `ImmutableArray<'T>.Builder.Replace` does, where `FlatList.replace` throws `ArgumentException`.
2828
* `flatList { }` builds a flat list.
2929
* `HashSet` has every function of the FSharp.Core `Set` module that applies to a hash set, with its semantics, argument
30-
order and exceptions, plus `builder`, `choose`, `clear`, `comparer`, `forComparer`, `ofBuilder`, `overlaps`, `setEquals`,
31-
`symmetricDifference`, `toBuilder` and `tryGetValue`.
32-
* `HashSet.forComparer comparer` creates the `CustomComparerHashSet` struct, whose members `empty`, `ofArray`, `ofList`,
33-
`ofSeq`, `singleton` and `builder` create hash sets and builders that compare with the comparer, as in
34-
`(HashSet.forComparer StringComparer.OrdinalIgnoreCase).ofSeq names`. `ofSeq` also gives an existing hash set the
35-
comparer. A `null` comparer throws `ArgumentNullException`.
30+
order and exceptions, plus `addRange`, `build`, `builder`, `choose`, `clear`, `comparer`, `forComparer`, `ofBuilder`,
31+
`ofReadOnlySpan`, `ofSpan`, `overlaps`, `removeRange`, `setEquals`, `symmetricDifference`, `toBuilder`, `tryGetValue`
32+
and `update`.
33+
* `HashSet.addRange elements set` and `removeRange elements set` wrap the `Union` and `Except` members that take a
34+
sequence. The result keeps the comparer of the hash set, an element of the sequence that the comparer finds equal to
35+
an element of the hash set does not replace it, and the input itself comes back when nothing changes.
36+
* `HashSet.ofReadOnlySpan` and `ofSpan` create a hash set from a span, `build` fills a builder with an action, and
37+
`update` applies an action to a builder of a hash set and returns its contents, so that the in-place operations of the
38+
builder, such as `IntersectWith`, are one expression.
39+
* `HashSet.forComparer comparer` creates the `CustomComparerHashSet` struct, whose members `build`, `builder`, `empty`,
40+
`ofArray`, `ofList`, `ofReadOnlySpan`, `ofSeq`, `ofSpan` and `singleton` create hash sets and builders that compare
41+
with the comparer, as in `(HashSet.forComparer StringComparer.OrdinalIgnoreCase).ofSeq names`. They replace the BCL
42+
members `Create(comparer, ...)`, `CreateRange(comparer, items)` and `CreateBuilder(comparer)`. `ofSeq` also gives an
43+
existing hash set the comparer, as `WithComparer` does: the hash set itself comes back for the same comparer
44+
instance, and an equal but distinct instance rebuilds it. `WithComparer(null)` is `HashSet.ofSeq set`. A `null`
45+
comparer throws `ArgumentNullException`.
46+
* `HashSet.add` and `remove` return the input itself when nothing changes, so a reference comparison of the input and
47+
the result tells whether `Add` changed anything, as the `bool` result of `Builder.Add` does. Hash sets have no builder
48+
module: `builder`, `toBuilder` and `ofBuilder` are `CreateBuilder`, `ToBuilder` and `ToImmutable`, and the builder is
49+
used directly.
3650
* The `ISet` module works on any `IImmutableSet<'T>` with the functions of `HashSet` that need neither a creation nor a
37-
comparer; the transformations that keep the element type return the implementation of their input.
51+
comparer, `addRange` and `removeRange` included; the transformations that keep the element type return the
52+
implementation of their input.
3853
* The `FSharp.Collections.Immutable.Option.HashSet`, `FSharp.Collections.Immutable.Tuple.HashSet`,
3954
`FSharp.Collections.Immutable.Option.ISet` and `FSharp.Collections.Immutable.Tuple.ISet` modules repeat `choose` and
4055
`tryGetValue` with options, and `partition` and `partitionWith` with reference tuples.
@@ -54,8 +69,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5469
* `FlatList.sub` has the meaning of `Array.sub`: `sub array startIndex count` returns `count` elements from `startIndex`.
5570
It was `sub start stop list`.
5671
* The nested `FlatList.Builder` module is now the `FlatListBuilder` module.
57-
* `HashSet`: `difference set1 set2` returns the elements of `set1` that are not in `set2`, as `Set.difference` does; it
58-
took its arguments in the reverse order before.
72+
* `HashSet`: `difference set1 set2` returns the elements of `set1` that are not in `set2`, as `Set.difference` does. In
73+
1.0.0 `difference values set` removed a sequence from a hash set: that is `removeRange values set` now, with the same
74+
order of the arguments. `union set values` of 1.0.0 is `addRange values set`.
75+
* `HashSet`: `union`, `intersect`, `isSubset`, `isProperSubset`, `isSuperset` and `isProperSuperset` took a sequence as
76+
the second argument in 1.0.0 and take a hash set now, as the `Set` functions do: pass `HashSet.ofSeq elements`, or
77+
`(HashSet.forComparer (HashSet.comparer set)).ofSeq elements` to give the elements the comparer of the first hash
78+
set. The BCL members that take a sequence map the same way: `Union` and `Except` are `addRange` and `removeRange`,
79+
`Overlaps` and `IsSupersetOf` are `Seq.exists` and `Seq.forall` with `contains`, and the others take `ofSeq` of the
80+
sequence.
81+
* `HashSet`: the element that stays when the comparer finds two elements equal follows the BCL: `union` and `addRange`
82+
keep the element of the first hash set, `intersect` keeps the elements of the second one, and the creation functions
83+
keep the first element of their input. `isProperSuperset` counts the elements of the second hash set that the
84+
comparer of the first one finds equal once, where `ImmutableHashSet.IsProperSupersetOf` counts each of them, against
85+
its documentation.
86+
* `HashSet`: the compiled name of the module is `HashSet`, which C# callers see; it was `ImmutableHashSetModule`.
5987
* `HashSet`: `length` is renamed to `count` and `keyComparer` to `comparer`.
6088
* `HashSet`: `filter`, `partition` and the set algebra keep the comparer of their input, the set algebra that of the first
6189
set; `map`, `choose` and `partitionWith` compare with the default comparer of the result type. `filter` dropped the
@@ -84,10 +112,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
84112
* The `ISet<'T>` abbreviation of `IImmutableSet<'T>`, because it shadowed `System.Collections.Generic.ISet<'T>`: use
85113
`IImmutableSet<'T>` and the `ISet` module.
86114
* The `HashSetBuilder<'T>` abbreviation: use `HashSet<'T>.Builder`.
87-
* `HashSet.where`: use `filter`. `HashSet.pick`, `tryPick` and `vTryPick`: use `Seq.pick` and `Seq.tryPick`. The public
115+
* `HashSet.where`: use `filter`. `HashSet.pick`, `tryPick` and `vTryPick`, which the FSharp.Core `Set` module does not
116+
have: use `HashSet.toSeq set |> Seq.pick chooser`, or `Seq.tryPick` and `ValueOption.ofOption`. The public
88117
`HashSet.check`.
89-
* `HashSet.ofComparer`, `ofSeqWithComparer`, `builderWithComparer` and `builderWith`, which took a comparer despite its
90-
name: use the members `empty`, `ofSeq` and `builder` of `HashSet.forComparer comparer`.
118+
* `HashSet.ofComparer comparer`, `ofSeqWithComparer comparer elements` and `builderWithComparer comparer`: use
119+
`(HashSet.forComparer comparer).empty`, `(HashSet.forComparer comparer).ofSeq elements` and
120+
`(HashSet.forComparer comparer).builder ()`. `HashSet.builderWith`, whose argument bound to the comparer overload of
121+
the BCL member, has no replacement: hash sets have no capacity.
91122

92123
## [1.0.0] - 2020-02-23
93124

0 commit comments

Comments
 (0)