HashSet Class

Immutable hash-set module

DECLARATION
public static partial class HashSet
NAMESPACE
LanguageExt

Methods

add<EqT, T>(HashSet<EqT, T>, T)
SUMMARY

Add an item to the set

PARAMETERS
set
HashSet<EqT, T>
Set to add item to
value
T
Value to add to the HSet
DECLARATION
[Pure]
public static HashSet<EqT, T> add<EqT, T>(HashSet<EqT, T> set, T value)
RETURNS
HashSet<EqT, T>
New set with the item added
CONSTRAINTS
where EqT : struct Eq<T>
add<T>(HashSet<T>, T)
SUMMARY

Add an item to the set

PARAMETERS
set
HashSet<T>
Set to add item to
value
T
Value to add to the HSet
DECLARATION
[Pure]
public static HashSet<T> add<T>(HashSet<T> set, T value)
RETURNS
HashSet<T>
New set with the item added
addOrUpdate<EqT, T>(HashSet<EqT, T>, T)
SUMMARY

Add an item to the set. If an item already exists then replace it.

PARAMETERS
set
HashSet<EqT, T>
Set to add item to
value
T
Value to add to the HSet
DECLARATION
[Pure]
public static HashSet<EqT, T> addOrUpdate<EqT, T>(HashSet<EqT, T> set, T value)
RETURNS
HashSet<EqT, T>
New set with the item maybe added
CONSTRAINTS
where EqT : struct Eq<T>
addOrUpdate<T>(HashSet<T>, T)
SUMMARY

Add an item to the set. If an item already exists then replace it.

PARAMETERS
set
HashSet<T>
Set to add item to
value
T
Value to add to the HSet
DECLARATION
[Pure]
public static HashSet<T> addOrUpdate<T>(HashSet<T> set, T value)
RETURNS
HashSet<T>
New set with the item maybe added
contains<EqT, T>(HashSet<EqT, T>, T)
SUMMARY

Returns True if the value is in the set

PARAMETERS
set
HashSet<EqT, T>
HSet
value
T
Value to check
DECLARATION
[Pure]
public static bool contains<EqT, T>(HashSet<EqT, T> set, T value)
RETURNS
bool
True if the item 'value' is in the Set 'set'
CONSTRAINTS
where EqT : struct Eq<T>
contains<T>(HashSet<T>, T)
SUMMARY

Returns True if the value is in the set

PARAMETERS
set
HashSet<T>
HSet
value
T
Value to check
DECLARATION
[Pure]
public static bool contains<T>(HashSet<T> set, T value)
RETURNS
bool
True if the item 'value' is in the Set 'set'
create<EqT, T>()
SUMMARY

Create a new empty set

DECLARATION
[Pure]
public static HashSet<EqT, T> create<EqT, T>()
RETURNS
HashSet<EqT, T>
Empty HSet
CONSTRAINTS
where EqT : struct Eq<T>
create<T>()
SUMMARY

Create a new empty set

DECLARATION
[Pure]
public static HashSet<T> create<T>()
RETURNS
HashSet<T>
Empty HSet
createRange<EqT, T>(IEnumerable<T>)
SUMMARY

Create a new set pre-populated with the items in range

PARAMETERS
range
IEnumerable<T>
Range of items
DECLARATION
[Pure]
public static HashSet<EqT, T> createRange<EqT, T>(IEnumerable<T> range)
RETURNS
HashSet<EqT, T>
HSet
CONSTRAINTS
where EqT : struct Eq<T>
createRange<T>(IEnumerable<T>)
SUMMARY

Create a new set pre-populated with the items in range

PARAMETERS
range
IEnumerable<T>
Range of items
DECLARATION
[Pure]
public static HashSet<T> createRange<T>(IEnumerable<T> range)
RETURNS
HashSet<T>
HSet
empty<EqT, T>()
SUMMARY

Create a new empty set

DECLARATION
[Pure]
public static HashSet<EqT, T> empty<EqT, T>()
RETURNS
HashSet<EqT, T>
Empty HSet
CONSTRAINTS
where EqT : struct Eq<T>
empty<T>()
SUMMARY

Create a new empty set

DECLARATION
[Pure]
public static HashSet<T> empty<T>()
RETURNS
HashSet<T>
Empty HSet
equals<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns true if both sets contain the same elements

PARAMETERS
setA
HashSet<EqT, T>
setB
HashSet<EqT, T>
DECLARATION
[Pure]
public static bool equals<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
bool
CONSTRAINTS
where EqT : struct Eq<T>
equals<T>(HashSet<T>, HashSet<T>)
SUMMARY

Returns true if both sets contain the same elements

PARAMETERS
setA
HashSet<T>
setB
HashSet<T>
DECLARATION
[Pure]
public static bool equals<T>(HashSet<T> setA, HashSet<T> setB)
RETURNS
bool
except<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns the elements that are in both setA and setB

PARAMETERS
setA
HashSet<EqT, T>
setB
HashSet<EqT, T>
DECLARATION
[Pure]
public static HashSet<EqT, T> except<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
HashSet<EqT, T>
CONSTRAINTS
where EqT : struct Eq<T>
except<T>(HashSet<T>, IEnumerable<T>)
SUMMARY

Returns the elements that are in both setA and setB

PARAMETERS
setA
HashSet<T>
setB
IEnumerable<T>
DECLARATION
[Pure]
public static HashSet<T> except<T>(HashSet<T> setA, IEnumerable<T> setB)
RETURNS
HashSet<T>
exists<EqT, T>(HashSet<EqT, T>, Func<T, bool>)
SUMMARY

Check the existence of an item in the set using a predicate.

PARAMETERS
set
HashSet<EqT, T>
HSet
pred
Func<T, bool>
Predicate
REMARKS
Note this scans the entire set.
DECLARATION
[Pure]
public static bool exists<EqT, T>(HashSet<EqT, T> set, Func<T, bool> pred)
RETURNS
bool
True if predicate returns true for any item
CONSTRAINTS
where EqT : struct Eq<T>
exists<T>(HashSet<T>, Func<T, bool>)
SUMMARY

Check the existence of an item in the set using a predicate.

PARAMETERS
set
HashSet<T>
HSet
pred
Func<T, bool>
Predicate
REMARKS
Note this scans the entire set.
DECLARATION
[Pure]
public static bool exists<T>(HashSet<T> set, Func<T, bool> pred)
RETURNS
bool
True if predicate returns true for any item
filter<EqT, T>(HashSet<EqT, T>, Func<T, bool>)
SUMMARY

Filters items from the set using the predicate. If the predicate returns True for any item then it remains in the set, otherwise it's dropped.

PARAMETERS
set
HashSet<EqT, T>
HSet
pred
Func<T, bool>
Predicate
DECLARATION
[Pure]
public static HashSet<EqT, T> filter<EqT, T>(HashSet<EqT, T> set, Func<T, bool> pred)
RETURNS
HashSet<EqT, T>
Filtered enumerable
CONSTRAINTS
where EqT : struct Eq<T>
filter<T>(HashSet<T>, Func<T, bool>)
SUMMARY

Filters items from the set using the predicate. If the predicate returns True for any item then it remains in the set, otherwise it's dropped.

PARAMETERS
set
HashSet<T>
HSet
pred
Func<T, bool>
Predicate
DECLARATION
[Pure]
public static HashSet<T> filter<T>(HashSet<T> set, Func<T, bool> pred)
RETURNS
HashSet<T>
Filtered enumerable
find<EqT, T>(HashSet<EqT, T>, T)
SUMMARY

Attempts to find an item in the set.

PARAMETERS
set
HashSet<EqT, T>
HSet
value
T
Value to find
DECLARATION
[Pure]
public static Option<T> find<EqT, T>(HashSet<EqT, T> set, T value)
RETURNS
Option<T>
Some(T) if found, None otherwise
CONSTRAINTS
where EqT : struct Eq<T>
find<T>(HashSet<T>, T)
SUMMARY

Attempts to find an item in the set.

PARAMETERS
set
HashSet<T>
HSet
value
T
Value to find
DECLARATION
[Pure]
public static Option<T> find<T>(HashSet<T> set, T value)
RETURNS
Option<T>
Some(T) if found, None otherwise
fold<EqT, T, S>(HashSet<EqT, T>, S, Func<S, T, S>)
SUMMARY

Applies a function 'folder' to each element of the collection, threading an accumulator argument through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the set. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result. (Aggregate in LINQ)

PARAMETERS
set
HashSet<EqT, T>
Set to fold
state
S
Initial state
folder
Func<S, T, S>
Fold function
DECLARATION
[Pure]
public static S fold<EqT, T, S>(HashSet<EqT, T> set, S state, Func<S, T, S> folder)
RETURNS
S
Aggregate value
CONSTRAINTS
where EqT : struct Eq<T>
fold<T, S>(HashSet<T>, S, Func<S, T, S>)
SUMMARY

Applies a function 'folder' to each element of the collection, threading an accumulator argument through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the set. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result. (Aggregate in LINQ)

PARAMETERS
set
HashSet<T>
Set to fold
state
S
Initial state
folder
Func<S, T, S>
Fold function
DECLARATION
[Pure]
public static S fold<T, S>(HashSet<T> set, S state, Func<S, T, S> folder)
RETURNS
S
Aggregate value
foldBack<EqT, T, S>(HashSet<EqT, T>, S, Func<S, T, S>)
SUMMARY

Applies a function 'folder' to each element of the collection (from last element to first), threading an aggregate state through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the set. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

PARAMETERS
set
HashSet<EqT, T>
Set to fold
state
S
Initial state
folder
Func<S, T, S>
Fold function
DECLARATION
[Pure]
public static S foldBack<EqT, T, S>(HashSet<EqT, T> set, S state, Func<S, T, S> folder)
RETURNS
S
Aggregate value
CONSTRAINTS
where EqT : struct Eq<T>
foldBack<T, S>(HashSet<T>, S, Func<S, T, S>)
SUMMARY

Applies a function 'folder' to each element of the collection (from last element to first), threading an aggregate state through the computation. The fold function takes the state argument, and applies the function 'folder' to it and the first element of the set. Then, it feeds this result into the function 'folder' along with the second element, and so on. It returns the final result.

PARAMETERS
set
HashSet<T>
Set to fold
state
S
Initial state
folder
Func<S, T, S>
Fold function
DECLARATION
[Pure]
public static S foldBack<T, S>(HashSet<T> set, S state, Func<S, T, S> folder)
RETURNS
S
Aggregate value
intersect<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns the elements that are in both setA and setB

PARAMETERS
setA
HashSet<EqT, T>
setB
HashSet<EqT, T>
DECLARATION
[Pure]
public static HashSet<EqT, T> intersect<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
HashSet<EqT, T>
CONSTRAINTS
where EqT : struct Eq<T>
intersect<T>(HashSet<T>, IEnumerable<T>)
SUMMARY

Returns the elements that are in both setA and setB

PARAMETERS
setA
HashSet<T>
setB
IEnumerable<T>
DECLARATION
[Pure]
public static HashSet<T> intersect<T>(HashSet<T> setA, IEnumerable<T> setB)
RETURNS
HashSet<T>
isEmpty<EqT, T>(HashSet<EqT, T>)
SUMMARY

True if the set has no elements

PARAMETERS
set
HashSet<EqT, T>
DECLARATION
[Pure]
public static bool isEmpty<EqT, T>(HashSet<EqT, T> set)
RETURNS
bool
True if the set has no elements
CONSTRAINTS
where EqT : struct Eq<T>
isEmpty<T>(HashSet<T>)
SUMMARY

True if the set has no elements

PARAMETERS
set
HashSet<T>
DECLARATION
[Pure]
public static bool isEmpty<T>(HashSet<T> set)
RETURNS
bool
True if the set has no elements
isProperSubHSet<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns True if setB is a proper subset of setA

PARAMETERS
setA
HashSet<EqT, T>
Set A
setB
HashSet<EqT, T>
Set B
DECLARATION
[Pure]
public static bool isProperSubHSet<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
bool
True is setB is a proper subset of setA
CONSTRAINTS
where EqT : struct Eq<T>
isProperSubHSet<T>(HashSet<T>, IEnumerable<T>)
SUMMARY

Returns True if setB is a proper subset of setA

PARAMETERS
setA
HashSet<T>
Set A
setB
IEnumerable<T>
Set B
DECLARATION
[Pure]
public static bool isProperSubHSet<T>(HashSet<T> setA, IEnumerable<T> setB)
RETURNS
bool
True is setB is a proper subset of setA
isProperSuperHSet<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns True if setB is a proper superset of setA

PARAMETERS
setA
HashSet<EqT, T>
Set A
setB
HashSet<EqT, T>
Set B
DECLARATION
[Pure]
public static bool isProperSuperHSet<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
bool
True is setB is a proper subset of setA
CONSTRAINTS
where EqT : struct Eq<T>
isProperSuperHSet<T>(HashSet<T>, IEnumerable<T>)
SUMMARY

Returns True if setB is a proper superset of setA

PARAMETERS
setA
HashSet<T>
Set A
setB
IEnumerable<T>
Set B
DECLARATION
[Pure]
public static bool isProperSuperHSet<T>(HashSet<T> setA, IEnumerable<T> setB)
RETURNS
bool
True is setB is a proper subset of setA
isSubHSet<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns True if setB is a subset of setA

PARAMETERS
setA
HashSet<EqT, T>
Set A
setB
HashSet<EqT, T>
Set B
DECLARATION
[Pure]
public static bool isSubHSet<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
bool
True is setB is a subset of setA
CONSTRAINTS
where EqT : struct Eq<T>
isSubHSet<T>(HashSet<T>, IEnumerable<T>)
SUMMARY

Returns True if setB is a subset of setA

PARAMETERS
setA
HashSet<T>
Set A
setB
IEnumerable<T>
Set B
DECLARATION
[Pure]
public static bool isSubHSet<T>(HashSet<T> setA, IEnumerable<T> setB)
RETURNS
bool
True is setB is a subset of setA
isSuperHSet<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns True if setB is a superset of setA

PARAMETERS
setA
HashSet<EqT, T>
Set A
setB
HashSet<EqT, T>
Set B
DECLARATION
[Pure]
public static bool isSuperHSet<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
bool
True is setB is a superset of setA
CONSTRAINTS
where EqT : struct Eq<T>
isSuperHSet<T>(HashSet<T>, IEnumerable<T>)
SUMMARY

Returns True if setB is a superset of setA

PARAMETERS
setA
HashSet<T>
Set A
setB
IEnumerable<T>
Set B
DECLARATION
[Pure]
public static bool isSuperHSet<T>(HashSet<T> setA, IEnumerable<T> setB)
RETURNS
bool
True is setB is a superset of setA
length<EqT, T>(HashSet<EqT, T>)
SUMMARY

Get the number of elements in the set

PARAMETERS
set
HashSet<EqT, T>
HSet
DECLARATION
[Pure]
public static int length<EqT, T>(HashSet<EqT, T> set)
RETURNS
int
Number of elements
CONSTRAINTS
where EqT : struct Eq<T>
length<T>(HashSet<T>)
SUMMARY

Get the number of elements in the set

PARAMETERS
set
HashSet<T>
HSet
DECLARATION
[Pure]
public static int length<T>(HashSet<T> set)
RETURNS
int
Number of elements
map<EqT, EqR, T, R>(HashSet<EqT, T>, Func<T, R>)
SUMMARY

Maps the values of this set into a new set of values using the mapper function to tranform the source values.

PARAMETERS
set
HashSet<EqT, T>
HSet
mapper
Func<T, R>
Mapping function
DECLARATION
[Pure]
public static HashSet<EqR, R> map<EqT, EqR, T, R>(HashSet<EqT, T> set, Func<T, R> mapper)
RETURNS
HashSet<EqR, R>
Mapped enumerable
CONSTRAINTS
where EqT : struct Eq<T>
where EqR : struct Eq<R>
map<EqT, T>(HashSet<EqT, T>, Func<T, T>)
SUMMARY

Maps the values of this set into a new set of values using the mapper function to tranform the source values.

PARAMETERS
set
HashSet<EqT, T>
HSet
mapper
Func<T, T>
Mapping function
DECLARATION
[Pure]
public static HashSet<EqT, T> map<EqT, T>(HashSet<EqT, T> set, Func<T, T> mapper)
RETURNS
HashSet<EqT, T>
Mapped enumerable
CONSTRAINTS
where EqT : struct Eq<T>
map<T, R>(HashSet<T>, Func<T, R>)
SUMMARY

Maps the values of this set into a new set of values using the mapper function to tranform the source values.

PARAMETERS
set
HashSet<T>
HSet
mapper
Func<T, R>
Mapping function
DECLARATION
[Pure]
public static HashSet<R> map<T, R>(HashSet<T> set, Func<T, R> mapper)
RETURNS
HashSet<R>
Mapped enumerable
overlaps<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns True if setA overlaps setB

PARAMETERS
setA
HashSet<EqT, T>
Set A
setB
HashSet<EqT, T>
Set B
DECLARATION
[Pure]
public static bool overlaps<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
bool
True if setA overlaps setB
CONSTRAINTS
where EqT : struct Eq<T>
overlaps<T>(HashSet<T>, IEnumerable<T>)
SUMMARY

Returns True if setA overlaps setB

PARAMETERS
setA
HashSet<T>
Set A
setB
IEnumerable<T>
Set B
DECLARATION
[Pure]
public static bool overlaps<T>(HashSet<T> setA, IEnumerable<T> setB)
RETURNS
bool
True if setA overlaps setB
remove<EqT, T>(HashSet<EqT, T>, T)
SUMMARY

Removes an item from the set (if it exists)

PARAMETERS
set
HashSet<EqT, T>
HSet
value
T
Value to check
DECLARATION
[Pure]
public static HashSet<EqT, T> remove<EqT, T>(HashSet<EqT, T> set, T value)
RETURNS
HashSet<EqT, T>
New set with item removed
CONSTRAINTS
where EqT : struct Eq<T>
remove<T>(HashSet<T>, T)
SUMMARY

Removes an item from the set (if it exists)

PARAMETERS
set
HashSet<T>
HSet
value
T
Value to check
DECLARATION
[Pure]
public static HashSet<T> remove<T>(HashSet<T> set, T value)
RETURNS
HashSet<T>
New set with item removed
subtract<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Returns setA - setB. Only the items in setA that are not in setB will be returned.

PARAMETERS
setA
HashSet<EqT, T>
setB
HashSet<EqT, T>
DECLARATION
[Pure]
public static HashSet<EqT, T> subtract<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
HashSet<EqT, T>
CONSTRAINTS
where EqT : struct Eq<T>
subtract<T>(HashSet<T>, HashSet<T>)
SUMMARY

Returns setA - setB. Only the items in setA that are not in setB will be returned.

PARAMETERS
setA
HashSet<T>
setB
HashSet<T>
DECLARATION
[Pure]
public static HashSet<T> subtract<T>(HashSet<T> setA, HashSet<T> setB)
RETURNS
HashSet<T>
symmetricExcept<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Only items that are in one set or the other will be returned. If an item is in both, it is dropped.

PARAMETERS
setA
HashSet<EqT, T>
setB
HashSet<EqT, T>
DECLARATION
[Pure]
public static HashSet<EqT, T> symmetricExcept<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
HashSet<EqT, T>
CONSTRAINTS
where EqT : struct Eq<T>
symmetricExcept<T>(HashSet<T>, IEnumerable<T>)
SUMMARY

Only items that are in one set or the other will be returned. If an item is in both, it is dropped.

PARAMETERS
setA
HashSet<T>
setB
IEnumerable<T>
DECLARATION
[Pure]
public static HashSet<T> symmetricExcept<T>(HashSet<T> setA, IEnumerable<T> setB)
RETURNS
HashSet<T>
tryAdd<EqT, T>(HashSet<EqT, T>, T)
SUMMARY

Attempt to add an item to the set. If an item already exists then return the Set as-is.

PARAMETERS
set
HashSet<EqT, T>
Set to add item to
value
T
Value to add to the HSet
DECLARATION
[Pure]
public static HashSet<EqT, T> tryAdd<EqT, T>(HashSet<EqT, T> set, T value)
RETURNS
HashSet<EqT, T>
New set with the item maybe added
CONSTRAINTS
where EqT : struct Eq<T>
tryAdd<T>(HashSet<T>, T)
SUMMARY

Attempt to add an item to the set. If an item already exists then return the Set as-is.

PARAMETERS
set
HashSet<T>
Set to add item to
value
T
Value to add to the HSet
DECLARATION
[Pure]
public static HashSet<T> tryAdd<T>(HashSet<T> set, T value)
RETURNS
HashSet<T>
New set with the item maybe added
union<EqT, T>(HashSet<EqT, T>, HashSet<EqT, T>)
SUMMARY

Finds the union of two sets and produces a new set with the results

PARAMETERS
setA
HashSet<EqT, T>
Set A
setB
HashSet<EqT, T>
Set A
DECLARATION
[Pure]
public static HashSet<EqT, T> union<EqT, T>(HashSet<EqT, T> setA, HashSet<EqT, T> setB)
RETURNS
HashSet<EqT, T>
A set which contains all items from both sets
CONSTRAINTS
where EqT : struct Eq<T>
union<T>(HashSet<T>, HashSet<T>)
SUMMARY

Finds the union of two sets and produces a new set with the results

PARAMETERS
setA
HashSet<T>
Set A
setB
HashSet<T>
Set A
DECLARATION
[Pure]
public static HashSet<T> union<T>(HashSet<T> setA, HashSet<T> setB)
RETURNS
HashSet<T>
A set which contains all items from both sets