[Home] Type Microsoft.FSharp.Collections.Set


Immutable sets based on binary trees, where comparison is the F# structural comparison function, potentially using implementations of the IComparable interface on key values. See the Set module for further operations on sets. These sets can be used with elements of any type, but you should check that structural hashing and equality on the element type are correct for your type. Efficiency: Structural comparison is relatively efficient but is not a suitable choice in all circumstances, e.g. it may not compare efficiently on non-reference types and deeply-structured types.

Full Type Signature

type Set<'a>
  with
    interface IComparable
    interface IEnumerable
    interface IEnumerable<'a>
    interface ICollection<'a>
    member Add : 'a -> Set<'a>
    static member Compare : a:Set<'a> * b:Set<'a> -> int
    member Contains : 'a -> bool
    static member Create : seq<'a> -> Set<'a>
    [<Obsolete ("Consider using Set.Empty instead")>]
    static member Create : unit -> Set<'a>
    static member Difference : Set<'a> * Set<'a> -> Set<'a>
    static member Empty : unit -> Set<'a>
    static member Equality : Set<'a> * Set<'a> -> bool
    override Equals : obj -> bool
    member Exists : ('a -> bool) -> bool
    member Filter : ('a -> bool) -> Set<'a>
    member Fold : ('a -> 'b -> 'b) -> ('b -> 'b)
    member ForAll : ('a -> bool) -> bool
    static member FromArray : 'a array -> Set<'a>
    member GetNextElement : 'a -> 'a option
    member GetPreviousElement : 'a -> 'a option
    static member Intersection : seq<Set<'a>> -> Set<'a>
    static member Intersection : Set<'a> * Set<'a> -> Set<'a>
    member IsSubsetOf : Set<'a> -> bool
    member IsSupersetOf : Set<'a> -> bool
    member Iterate : ('a -> unit) -> unit
    member Map : ('a -> 'b) -> Set<'b>
    member Partition : ('a -> bool) -> Set<'a> * Set<'a>
    member Remove : 'a -> Set<'a>
    static member Singleton : 'a -> Set<'a>
    member ToArray : unit -> 'a array
    member ToList : unit -> 'a list
    static member Union : seq<Set<'a>> -> Set<'a>
    static member Union : Set<'a> * Set<'a> -> Set<'a>
    [<Obsolete ("This property will be removed in a later release")>]
    member CheckBalanceInvariant : bool
    member Choose : 'a
    member Count : int
    member IsEmpty : bool
    member MaximumElement : 'a
    member MinimumElement : 'a
    [<Obsolete ("Please use the .Count property instead")>]
    member Size : int
    static member ( + ) : Set<'a> * Set<'a> -> Set<'a>
    static member ( - ) : Set<'a> * Set<'a> -> Set<'a>
  end

Instance Members

MemberDescription
member Add : 'a -> Set<'a>
A useful shortcut for Set.add. Note this operation prodcues 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.
member Choose : 'a
Returns the lowest element in the set according to the ordering being used for the set
member Contains : 'a -> bool
A useful shortcut for Set.mem. See the Set module for further operations on sets.
member Count : int
The number of elements in the set
override Equals : obj -> bool
member Exists : ('a -> bool) -> bool
Test if any element of the collection satisfies the given predicate. If the elements are "i0...iN" then computes "p i0 or ... or p iN".
member Filter : ('a -> bool) -> Set<'a>
Return a new collection containing only the elements of the collection for which the given predicate returns "true"
member Fold : ('a -> 'b -> 'b) -> ('b -> 'b)
Apply the given accumulating function to all the elements of the set
member ForAll : ('a -> bool) -> bool
Test if all elements of the collection satisfy the given predicate. If the elements are "i0...iN" and "j0...jN" then computes "p i0 && ... && p iN".
member GetNextElement : 'a -> 'a option
Returns the least element in the set that is greater than the given key according to the ordering being used for the set
member GetPreviousElement : 'a -> 'a option
Returns the greatest element in the set that is less than the given key according to the ordering being used for the set
member IsEmpty : bool
A useful shortcut for Set.is_empty. See the Set module for further operations on sets.
member IsSubsetOf : Set<'a> -> bool
Evaluates to "true" if all elements of the second set are in the first
member IsSupersetOf : Set<'a> -> bool
Evaluates to "true" if all elements of the first set are in the second
member Iterate : ('a -> unit) -> unit
Apply the given function to each binding in the collection
member Map : ('a -> 'b) -> Set<'b>
Return a new collection containing the results of applying the given function to each element of the input set
member MaximumElement : 'a
Returns the highest element in the set according to the ordering being used for the set
member MinimumElement : 'a
Returns the lowest element in the set according to the ordering being used for the set
member Partition : ('a -> bool) -> Set<'a> * Set<'a>
Build two new sets, one containing the elements for which the given predicate returns 'true', and the other the remaining elements.
member Remove : 'a -> Set<'a>
A useful shortcut for Set.remove. Note this operation prodcues 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.
member ToArray : unit -> 'a array
The elements of the set as an array.
member ToList : unit -> 'a list
The elements of the set as a list.

Static Members

MemberDescription
member ( + ) : Set<'a> * Set<'a> -> Set<'a>
Compute the union of the two sets.
member ( - ) : Set<'a> * Set<'a> -> Set<'a>
Return a new set with the elements of the second set removed from the first.
member Compare : a:Set<'a> * b:Set<'a> -> int
Compares a and b and returns 1 if a > b, -1 if b < a and 0 if a = b
member Create : seq<'a> -> Set<'a>
Build a set that contains the same elements as the given IEnumerable
member Difference : Set<'a> * Set<'a> -> Set<'a>
Return a new set with the elements of the second set removed from the first.
member Empty : unit -> Set<'a>
The empty set based on the default structural comparison operator
member Equality : Set<'a> * Set<'a> -> bool
Compares two sets and returns true if they are equal or false otherwise
member FromArray : 'a array -> Set<'a>
Build a set that contains the same elements as the given array
member Intersection : seq<Set<'a>> -> Set<'a>
Compute the intersection of N sets. At least one set must be given.
member Intersection : Set<'a> * Set<'a> -> Set<'a>
Compute the intersection of the two sets.
member Singleton : 'a -> Set<'a>
A singleton set based on the default structural comparison operator
member Union : seq<Set<'a>> -> Set<'a>
Compute the union of multiple sets.
member Union : Set<'a> * Set<'a> -> Set<'a>
Compute the union of the two sets.

Deprecated Members

MemberDescription
[<Obsolete ("This property will be removed in a later release")>]
member CheckBalanceInvariant : bool

Note: This property will be removed in a later release

[<Obsolete ("Consider using Set.Empty instead")>]
member Create : unit -> Set<'a>

Note: Consider using Set.Empty instead

[<Obsolete ("Please use the .Count property instead")>]
member Size : int

Note: Please use the .Count property instead

A useful shortcut for Set.size. See the Set module for further operations on sets.

See Also

Microsoft.FSharp.Collections


Documentation for assembly FSharp.Core, version 1.9.4.19, generated using F# version 1.9.4.19