Immutable sets based on binary trees, where elements are ordered by F# generic comparison. By default comparison is the F# structural comparison function or uses implementations of the IComparable interface on element values.
See the Set module for further operations on sets. All members of this class are thread-safe and may be used concurrently from multiple threads.
Constructor | Description |
|
Example
let sequenceOfNumbers = seq { 1 .. 3 } let numbersInSet = Set(sequenceOfNumbers) printfn $"The set is {numbersInSet}" |
Instance member | Description |
![]() ![]() ![]() ![]() ![]() ![]() A useful shortcut for Set.add. Note this operation produces a new set and does not mutate the original set. The new set will share many storage nodes with the original. See the Set module for further operations on sets.
Example
let set = Set.empty.Add(1).Add(1).Add(2) printfn $"The new set is: {set}"The sample evaluates to the following output: The new set is: set [1; 2]
|
|
Full Usage:
this.Contains
Parameters:
'T
-
The value to check.
Returns: bool
True if the set contains value .
|
Example
let set = Set.empty.Add(2).Add(3) printfn $"Does the set contain 1? {set.Contains(1)}"The sample evaluates to the following output: Does the set contain 1? false
|
|
Example
let set = Set.empty.Add(1).Add(1).Add(2) printfn $"The set has {set.Count} elements"The sample evaluates to the following output: The set has 3 elements
|
|
Example
let set = Set.empty.Add(2).Add(3) printfn $"Is the set empty? {set.IsEmpty}"The sample evaluates to the following output: Is the set empty? false
|
|
![]() ![]() ![]() ![]() ![]() ![]() Evaluates to "true" if all elements of the first set are in the second, and at least one element of the second is not in the first.
Example
let set1 = Set.empty.Add(1).Add(2).Add(3) let set2 = Set.empty.Add(1).Add(2).Add(3).Add(4) printfn $"Is {set1} a proper superset of {set2}? {Set.isProperSuperset set1 set2}"The sample evaluates to the following output: Is set [1; 2; 3] a proper subset of set [1; 2; 3; 4]? true
|
|
![]() ![]() ![]() ![]() ![]() ![]() Evaluates to "true" if all elements of the second set are in the first, and at least one element of the first is not in the second.
Example
let set1 = Set.empty.Add(1).Add(2).Add(3) let set2 = Set.empty.Add(1).Add(2).Add(3).Add(4) printfn $"Is {set1} a proper superset of {set2}? {Set.isProperSuperset set1 set2}"The sample evaluates to the following output: Is set [1; 2; 3] a proper superset of set [1; 2; 3; 4]? false
|
|
Example
let set1 = Set.empty.Add(1).Add(2).Add(3) let set2 = Set.empty.Add(1).Add(2).Add(3).Add(4) printfn $"Is {set1} a subset of {set2}? {Set.isSubset set1 set2}"The sample evaluates to the following output: Is set [1; 2; 3] a subset of set [1; 2; 3; 4]? true
|
|
Example
let set1 = Set.empty.Add(1).Add(2).Add(3) let set2 = Set.empty.Add(1).Add(2).Add(3).Add(4) printfn $"Is {set1} a superset of {set2}? {Set.isSuperset set1 set2}"The sample evaluates to the following output: Is set [1; 2; 3] a superset of set [1; 2; 3; 4]? false
|
Full Usage:
this.MaximumElement
Returns: 'T
|
Example
let set = Set.empty.Add(1).Add(2).Add(3) printfn $"MaximumElement: {set.MaximumElement}"The sample evaluates to the following output: MaximumElement: 3
|
Full Usage:
this.MinimumElement
Returns: 'T
|
Example
let set = Set.empty.Add(1).Add(2).Add(3) printfn $"MinimumElement: {set.MinimumElement}"The sample evaluates to the following output: MinimumElement: 1
|
Full Usage:
this.Remove
Parameters:
'T
-
The value to remove from the set.
Returns: Set<'T>
The result set.
|
![]() ![]() ![]() ![]() ![]() ![]() A useful shortcut for Set.remove. Note this operation produces a new set and does not mutate the original set. The new set will share many storage nodes with the original. See the Set module for further operations on sets.
Example
let set = Set.empty.Add(1).Add(1).Add(2) printfn $"The new set is: {set}"The sample evaluates to the following output: The new set is: set [2]
|
Static member | Description |
|
Example
let set1 = Set.empty.Add(1).Add(2).Add(3) let set2 = Set.empty.Add(2).Add(3).Add(4) printfn $"Output is %A" {set1 + set2}"The sample evaluates to the following output: The new set is: set [1; 2; 3; 4]
|
|
Example
let set1 = Set.empty.Add(1).Add(2).Add(3) let set2 = Set.empty.Add(2).Add(3).Add(4) printfn $"The new set is: {set1 - set2}"The sample evaluates to the following output: The new set is: set [1]
|