Set<'T> Type
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.
Constructors
Constructor | Description |
|
Example
val sequenceOfNumbers: int seq
Multiple items
val seq: sequence: 'T seq -> 'T seq -------------------- type 'T seq = System.Collections.Generic.IEnumerable<'T> val numbersInSet: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val printfn: format: Printf.TextWriterFormat<'T> -> 'T
|
Instance members
Instance member | Description |
Example
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
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
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
member Set.Contains: value: 'T -> bool
The sample evaluates to the following output: Does the set contain 1? false
|
|
Example
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
property Set.Count: int with get
The sample evaluates to the following output: The set has 3 elements
|
|
Example
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
property Set.IsEmpty: bool with get
The sample evaluates to the following output: Is the set empty? false
|
|
Example
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: Is set [1; 2; 3] a proper subset of set [1; 2; 3; 4]? true
|
|
Example
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: Is set [1; 2; 3] a proper superset of set [1; 2; 3; 4]? false
|
|
Example
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: Is set [1; 2; 3] a subset of set [1; 2; 3; 4]? true
|
|
Example
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
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
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
property Set.MaximumElement: int with get
The sample evaluates to the following output: MaximumElement: 3
|
Full Usage:
this.MinimumElement
Returns: 'T
|
Example
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
property Set.MinimumElement: int with get
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.
|
Example
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The new set is: set [2]
|
Static members
Static member | Description |
|
Example
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The new set is: set [1; 2; 3; 4]
|
|
Example
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The new set is: set [1]
|