LanguageExt.Core

LanguageExt.Core Immutable Collections Set

Contents

struct Set <A> Source #

Immutable set AVL tree implementation AVL tree is a self-balancing binary search tree. wikipedia.org/wiki/AVL_tree

Parameters

type A

Set item type

Properties

property Set<A> Empty Source #

property object? Case Source #

Reference version for use in pattern-matching

Empty collection     = null
Singleton collection = A
More                 = (A, Seq<A>)   -- head and tail

var res = set.Case switch
{

   (var x, var xs) => ...,
   A value         => ...,
   _               => ...
}

property bool IsEmpty Source #

Is the set empty

property int Count Source #

Number of items in the set

property int Length Source #

Alias of Count

property Option<A> Min Source #

Find the lowest ordered item in the set

property Option<A> Max Source #

Find the highest ordered item in the set

property Set<A> AdditiveIdentity Source #

Constructors

constructor Set (IEnumerable<A> items) Source #

Ctor from an enumerable

constructor Set (ReadOnlySpan<A> items) Source #

Ctor from an enumerable

constructor Set (IEnumerable<A> items, bool tryAdd) Source #

Ctor that takes an initial (distinct) set of items

Parameters

param items

constructor Set (ReadOnlySpan<A> items, bool tryAdd) Source #

Ctor that takes an initial (distinct) set of items

Parameters

param items

Methods

method Lens<Set<A>, bool> item (A key) Source #

Item at index lens

method Lens<Set<A>, Set<A>> map (Lens<A, A> lens) Source #

Lens map

method Set<A> Add (A value) Source #

Add an item to the set

Parameters

param value

Value to add to the set

returns

New set with the item added

method Set<A> TryAdd (A value) Source #

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

Parameters

param value

Value to add to the set

returns

New set with the item maybe added

method Set<A> AddOrUpdate (A value) Source #

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

Parameters

param value

Value to add to the set

returns

New set with the item maybe added

method Set<A> AddRange (IEnumerable<A> range) Source #

Atomically adds a range of items to the set.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Set<A> TryAddRange (IEnumerable<A> range) Source #

Atomically adds a range of items to the set. If an item already exists, it's ignored.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Set<A> AddOrUpdateRange (IEnumerable<A> range) Source #

Atomically adds a range of items to the set. If an item already exists then replace it.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Option<A> Find (A value) Source #

Attempts to find an item in the set.

Parameters

param value

Value to find

returns

Some(T) if found, None otherwise

method EnumerableM<A> FindRange (A keyFrom, A keyTo) Source #

Retrieve a range of values

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Range of values

method Option<A> FindPredecessor (A key) Source #

Retrieve the value from previous item to specified key

Parameters

param key

Key to find

returns

Found key

method Option<A> FindExactOrPredecessor (A key) Source #

Retrieve the value from exact key, or if not found, the previous item

Parameters

param key

Key to find

returns

Found key

method Option<A> FindSuccessor (A key) Source #

Retrieve the value from next item to specified key

Parameters

param key

Key to find

returns

Found key

method Option<A> FindExactOrSuccessor (A key) Source #

Retrieve the value from exact key, or if not found, the next item

Parameters

param key

Key to find

returns

Found key

method Set<A> Intersect (IEnumerable<A> other) Source #

Returns the elements that are in both this and other

method Set<A> Except (IEnumerable<A> other) Source #

Returns this - other. Only the items in this that are not in other will be returned.

method Set<A> Except (Set<A> other) Source #

Returns this - other. Only the items in this that are not in other will be returned.

method Set<A> SymmetricExcept (IEnumerable<A> other) Source #

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

method Set<A> SymmetricExcept (Set<A> other) Source #

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

method Set<A> Union (IEnumerable<A> other) Source #

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

Parameters

param other

Other set to union with

returns

A set which contains all items from both sets

method Set<A> Clear () Source #

Clears the set

Parameters

returns

An empty set

method IEnumerator<A> GetEnumerator () Source #

Get enumerator

Parameters

returns

IEnumerator T

method Set<A> Remove (A value) Source #

Removes an item from the set (if it exists)

Parameters

param value

Value to remove

returns

New set with item removed

method Set<A> RemoveRange (IEnumerable<A> values) Source #

Removes a range of items from the set (if they exist)

Parameters

param value

Value to remove

returns

New set with items removed

method Set<A> Do (Action<A> f) Source #

Impure iteration of the bound value in the structure

Parameters

returns

Returns the original unmodified structure

method Set<B> Map <B> (Func<A, B> map) Source #

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

Parameters

type R

Mapped element type

param mapper

Mapping function

returns

Mapped Set

method K<F, Set<B>> Traverse <F, B> (Func<A, K<F, B>> f) Source #

where F : Applicative<F>

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Parameters

type F

Applicative functor trait

type B

Bound value (output)

param f
param ta

Traversable structure

method Set<A> Filter (Func<A, bool> pred) Source #

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

param pred

Predicate

returns

Filtered enumerable

method bool Exists (Func<A, bool> pred) Source #

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

Note this scans the entire set.

Parameters

param pred

Predicate

returns

True if predicate returns true for any item

method bool Contains (A value) Source #

Returns True if the value is in the set

Parameters

param value

Value to check

returns

True if the item 'value' is in the Set 'set'

method bool SetEquals (IEnumerable<A> other) Source #

Returns true if both sets contain the same elements

Parameters

param other

Other distinct set to compare

returns

True if the sets are equal

method bool IsProperSubsetOf (IEnumerable<A> other) Source #

Returns True if 'other' is a proper subset of this set

Parameters

returns

True if 'other' is a proper subset of this set

method bool IsProperSupersetOf (IEnumerable<A> other) Source #

Returns True if 'other' is a proper superset of this set

Parameters

returns

True if 'other' is a proper superset of this set

method bool IsSubsetOf (IEnumerable<A> other) Source #

Returns True if 'other' is a superset of this set

Parameters

returns

True if 'other' is a superset of this set

method bool IsSupersetOf (IEnumerable<A> other) Source #

Returns True if 'other' is a superset of this set

Parameters

returns

True if 'other' is a superset of this set

method bool Overlaps (IEnumerable<A> other) Source #

Returns True if other overlaps this set

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True if other overlaps this set

method void CopyTo (A[] array, int index) Source #

Copy the items from the set into the specified array

Parameters

param array

Array to copy to

param index

Index into the array to start

method void CopyTo (Array array, int index) Source #

Copy the items from the set into the specified array

Parameters

param array

Array to copy to

param index

Index into the array to start

method Set<A> Combine (Set<A> rhs) Source #

Append performs a union of the two sets

Parameters

param rhs

Right hand side set

returns

Unioned set

method Set<A> Subtract (Set<A> rhs) Source #

Subtract operator - performs a subtract of the two sets

Parameters

param rhs

Right hand side set

returns

Subtracted set

method bool Equals (Set<A> other) Source #

Equality test

Parameters

param other

Other set to test

returns

True if sets are equal

method bool Equals (object? obj) Source #

Equality override

method int GetHashCode () Source #

Get the hash code. Calculated from all items in the set.

The hash-code is cached after the first read.

method int CompareTo (object? obj) Source #

method string ToString () Source #

Format the collection as [a, b, c, ...] The ellipsis is used for collections over 50 items To get a formatted string with all the items, use ToFullString or ToFullArrayString.

method string ToFullString (string separator = ", ") Source #

Format the collection as a, b, c, ...

method string ToFullArrayString (string separator = ", ") Source #

Format the collection as [a, b, c, ...]

method Seq<A> ToSeq () Source #

method EnumerableM<A> AsEnumerable () Source #

method Set<B> Select <B> (Func<A, B> f) Source #

method Set<A> Where (Func<A, bool> pred) Source #

method Set<B> Bind <B> (Func<A, Set<B>> f) Source #

method Set<C> SelectMany <B, C> (Func<A, Set<B>> bind, Func<A, B, C> project) Source #

method EnumerableM<A> Skip (int amount) Source #

method int CompareTo (Set<A> other) Source #

method int CompareTo <OrdA> (Set<A> other) Source #

where OrdA : Ord<A>

method Set<A> Slice (A keyFrom, A keyTo) Source #

Creates a new map from a range/slice of this map

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Operators

operator + (Set<A> lhs, Set<A> rhs) Source #

Add operator + performs a union of the two sets

Parameters

param lhs

Left hand side set

param rhs

Right hand side set

returns

Unioned set

operator - (Set<A> lhs, Set<A> rhs) Source #

Subtract operator - performs a subtract of the two sets

Parameters

param lhs

Left hand side set

param rhs

Right hand side set

returns

Subtractd set

operator == (Set<A> lhs, Set<A> rhs) Source #

Equality operator

Parameters

param lhs

Left hand side set

param rhs

Right hand side set

returns

True if the two sets are equal

operator != (Set<A> lhs, Set<A> rhs) Source #

Non-equality operator

Parameters

param lhs

Left hand side set

param rhs

Right hand side set

returns

True if the two sets are equal

operator < (Set<A> lhs, Set<A> rhs) Source #

operator <= (Set<A> lhs, Set<A> rhs) Source #

operator > (Set<A> lhs, Set<A> rhs) Source #

operator >= (Set<A> lhs, Set<A> rhs) Source #

class SetExtensions Source #

Methods

method Set<A> As <A> (this K<Set, A> ma) Source #

method IQueryable<A> AsQueryable <A> (this Set<A> source) Source #

Convert to a queryable

class SetEnumerator <K> Source #

Properties

property K Current Source #

Constructors

constructor SetEnumerator (SetItem<K> root, bool rev, int start) Source #

Methods

method void Dispose () Source #

method bool MoveNext () Source #

method void Reset () Source #

class Set Source #

Methods

method bool isEmpty <T> (Set<T> set) Source #

True if the set has no elements

Parameters

type T

Element type

returns

True if the set has no elements

method Set<A> singleton <A> (A value) Source #

Singleton set

method Set<T> create <T> () Source #

Create a new empty set

Parameters

type T

Element type

returns

Empty set

method Set<T> createRange <T> (IEnumerable<T> range) Source #

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

Parameters

type T

Element type

param range

Range of items

returns

Set

method Set<A> createRange <A> (ReadOnlySpan<A> range) Source #

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

Parameters

type T

Element type

param range

Range of items

returns

Set

method Set<T> empty <T> () Source #

Create a new empty set

Parameters

type T

Element type

returns

Empty set

method Set<T> add <T> (Set<T> set, T value) Source #

Add an item to the set

Parameters

type T

Element type

param set

Set to add item to

param value

Value to add to the set

returns

New set with the item added

method Set<T> tryAdd <T> (Set<T> set, T value) Source #

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

Parameters

type T

Element type

param set

Set to add item to

param value

Value to add to the set

returns

New set with the item maybe added

method Set<T> addOrUpdate <T> (Set<T> set, T value) Source #

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

Parameters

type T

Element type

param set

Set to add item to

param value

Value to add to the set

returns

New set with the item maybe added

method Set<A> addRange <A> (Set<A> set, IEnumerable<A> range) Source #

Atomically adds a range of items to the set.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Set<A> tryAddRange <A> (Set<A> set, IEnumerable<A> range) Source #

Atomically adds a range of items to the set. If an item already exists, it's ignored.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Set<A> addOrUpdateRange <A> (Set<A> set, IEnumerable<A> range) Source #

Atomically adds a range of items to the set. If an item already exists then replace it.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Option<T> find <T> (Set<T> set, T value) Source #

Attempts to find an item in the set.

Parameters

type T

Element type

param set

Set

param value

Value to find

returns

Some(T) if found, None otherwise

method bool exists <T> (Set<T> set, Func<T, bool> pred) Source #

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

Note this scans the entire set.

Parameters

type T

Element type

param set

Set

param pred

Predicate

returns

True if predicate returns true for any item

method bool equals <T> (Set<T> setA, Set<T> setB) Source #

Returns true if both sets contain the same elements

method int length <T> (Set<T> set) Source #

Get the number of elements in the set

Parameters

type T

Element type

param set

Set

returns

Number of elements

method Set<T> subtract <T> (Set<T> setA, Set<T> setB) Source #

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

method Set<T> union <T> (Set<T> setA, Set<T> setB) Source #

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

Parameters

type T

Element type

param setA

Set A

param setB

Set A

returns

A set which contains all items from both sets

method Set<T> filter <T> (Set<T> set, Func<T, bool> pred) Source #

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

type T

Element type

param set

Set

param pred

Predicate

returns

Filtered enumerable

method S fold <T, S> (Set<T> set, S state, Func<S, T, S> folder) Source #

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

type S

State type

type T

Set element type

param set

Set to fold

param state

Initial state

param folder

Fold function

returns

Aggregate value

method S foldBack <T, S> (Set<T> set, S state, Func<S, T, S> folder) Source #

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

type S

State type

type T

Set element type

param set

Set to fold

param state

Initial state

param folder

Fold function

returns

Aggregate value

method Set<T> intersect <T> (Set<T> setA, IEnumerable<T> setB) Source #

Returns the elements that are in both setA and setB

method Set<T> except <T> (Set<T> setA, IEnumerable<T> setB) Source #

Returns this - other. Only the items in this that are not in other will be returned.

method Set<T> symmetricExcept <T> (Set<T> setA, IEnumerable<T> setB) Source #

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

method Set<R> map <T, R> (Set<T> set, Func<T, R> mapper) Source #

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

Parameters

type T

Element type

type R

Mapped element type

param set

Set

param mapper

Mapping function

returns

Mapped enumerable

method bool contains <T> (Set<T> set, T value) Source #

Returns True if the value is in the set

Parameters

type T

Element type

param set

Set

param value

Value to check

returns

True if the item 'value' is in the Set 'set'

method Set<T> remove <T> (Set<T> set, T value) Source #

Removes an item from the set (if it exists)

Parameters

type T

Element type

param set

Set

param value

Value to check

returns

New set with item removed

method bool isSubset <T> (Set<T> setA, IEnumerable<T> setB) Source #

Returns True if setB is a subset of setA

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True is setB is a subset of setA

method bool isSuperset <T> (Set<T> setA, IEnumerable<T> setB) Source #

Returns True if setB is a superset of setA

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True is setB is a superset of setA

method bool isProperSubset <T> (Set<T> setA, IEnumerable<T> setB) Source #

Returns True if setB is a proper subset of setA

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True is setB is a proper subset of setA

method bool isProperSuperset <T> (Set<T> setA, IEnumerable<T> setB) Source #

Returns True if setB is a proper superset of setA

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True is setB is a proper subset of setA

method bool overlaps <T> (Set<T> setA, IEnumerable<T> setB) Source #

Returns True if setA overlaps setB

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True if setA overlaps setB

class Set Source #

struct Set <OrdA, A> Source #

where OrdA : Ord<A>

Immutable set AVL tree implementation AVL tree is a self-balancing binary search tree. wikipedia.org/wiki/AVL_tree

Parameters

type A

Set item type

Properties

property object? Case Source #

Reference version for use in pattern-matching

Empty collection     = null
Singleton collection = A
More                 = (A, Seq<A>)   -- head and tail

var res = set.Case switch
{

   (var x, var xs) => ...,
   A value         => ...,
   _               => ...
}

property bool IsEmpty Source #

Is the set empty

property int Count Source #

Number of items in the set

property int Length Source #

Alias of Count

property Option<A> Min Source #

Find the lowest ordered item in the set

property Option<A> Max Source #

Find the highest ordered item in the set

Constructors

constructor Set (IEnumerable<A> items) Source #

Ctor from an enumerable

constructor Set (ReadOnlySpan<A> items) Source #

Ctor from an enumerable

constructor Set (IEnumerable<A> items, bool tryAdd) Source #

Ctor that takes an initial (distinct) set of items

Parameters

param items

constructor Set (ReadOnlySpan<A> items, bool tryAdd) Source #

Ctor that takes an initial (distinct) set of items

Parameters

param items

Methods

method Set<OrdA, A> Add (A value) Source #

Add an item to the set

Parameters

param value

Value to add to the set

returns

New set with the item added

method Set<OrdA, A> TryAdd (A value) Source #

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

Parameters

param value

Value to add to the set

returns

New set with the item maybe added

method Set<OrdA, A> AddOrUpdate (A value) Source #

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

Parameters

param value

Value to add to the set

returns

New set with the item maybe added

method Set<OrdA, A> AddRange (IEnumerable<A> range) Source #

Atomically adds a range of items to the set.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Set<OrdA, A> TryAddRange (IEnumerable<A> range) Source #

Atomically adds a range of items to the set. If an item already exists, it's ignored.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Set<OrdA, A> AddOrUpdateRange (IEnumerable<A> range) Source #

Atomically adds a range of items to the set. If an item already exists then replace it.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Option<A> Find (A value) Source #

Attempts to find an item in the set.

Parameters

param value

Value to find

returns

Some(T) if found, None otherwise

method Option<A> FindPredecessor (A key) Source #

Retrieve the value from previous item to specified key

Parameters

param key

Key to find

returns

Found key

method Option<A> FindExactOrPredecessor (A key) Source #

Retrieve the value from exact key, or if not found, the previous item

Parameters

param key

Key to find

returns

Found key

method Option<A> FindSuccessor (A key) Source #

Retrieve the value from next item to specified key

Parameters

param key

Key to find

returns

Found key

method Option<A> FindExactOrSuccessor (A key) Source #

Retrieve the value from exact key, or if not found, the next item

Parameters

param key

Key to find

returns

Found key

method EnumerableM<A> FindRange (A keyFrom, A keyTo) Source #

Retrieve a range of values

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Range of values

method Set<OrdA, A> Intersect (Set<OrdA, A> other) Source #

Returns the elements that are in both this and other

method Set<OrdA, A> Except (Set<OrdA, A> other) Source #

Returns this - other. Only the items in this that are not in other will be returned.

method Set<OrdA, A> Except (IEnumerable<A> other) Source #

Returns this - other. Only the items in this that are not in other will be returned.

method Set<OrdA, A> SymmetricExcept (Set<OrdA, A> other) Source #

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

method Set<OrdA, A> SymmetricExcept (IEnumerable<A> other) Source #

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

method Set<OrdA, A> Union (Set<OrdA, A> other) Source #

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

Parameters

param other

Other set to union with

returns

A set which contains all items from both sets

method Set<OrdA, A> Clear () Source #

Clears the set

Parameters

returns

An empty set

method IEnumerator<A> GetEnumerator () Source #

Get enumerator

Parameters

returns

IEnumerator T

method Set<OrdA, A> Remove (A value) Source #

Removes an item from the set (if it exists)

Parameters

param value

Value to check

returns

New set with item removed

method S Fold <S> (S state, Func<S, A, S> folder) Source #

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

type S

State type

param state

Initial state

param folder

Fold function

returns

Aggregate value

method S FoldBack <S> (S state, Func<S, A, S> folder) Source #

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

type S

State type

param state

Initial state

param folder

Fold function

returns

Aggregate value

method Set<OrdA, A> Do (Action<A> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method Set<OrdB, B> Map <OrdB, B> (Func<A, B> map) Source #

where OrdB : Ord<B>

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

Parameters

type R

Mapped element type

param mapper

Mapping function

returns

Mapped Set

method Set<OrdA, A> Map (Func<A, A> map) Source #

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

Parameters

type R

Mapped element type

param mapper

Mapping function

returns

Mapped Set

method Set<OrdA, A> Filter (Func<A, bool> pred) Source #

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

param pred

Predicate

returns

Filtered enumerable

method bool Exists (Func<A, bool> pred) Source #

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

Note this scans the entire set.

Parameters

param pred

Predicate

returns

True if predicate returns true for any item

method bool Contains (A value) Source #

Returns True if the value is in the set

Parameters

param value

Value to check

returns

True if the item 'value' is in the Set 'set'

method bool SetEquals (Set<OrdA, A> other) Source #

Returns true if both sets contain the same elements

Parameters

param other

Other distinct set to compare

returns

True if the sets are equal

method bool IsProperSubsetOf (Set<OrdA, A> other) Source #

Returns True if 'other' is a proper subset of this set

Parameters

returns

True if 'other' is a proper subset of this set

method bool IsProperSupersetOf (Set<OrdA, A> other) Source #

Returns True if 'other' is a proper superset of this set

Parameters

returns

True if 'other' is a proper superset of this set

method bool IsSubsetOf (Set<OrdA, A> other) Source #

Returns True if 'other' is a superset of this set

Parameters

returns

True if 'other' is a superset of this set

method bool IsSupersetOf (Set<OrdA, A> other) Source #

Returns True if 'other' is a superset of this set

Parameters

returns

True if 'other' is a superset of this set

method bool Overlaps (Set<OrdA, A> other) Source #

Returns True if other overlaps this set

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True if other overlaps this set

method void CopyTo (A[] array, int index) Source #

Copy the items from the set into the specified array

Parameters

param array

Array to copy to

param index

Index into the array to start

method void CopyTo (Array array, int index) Source #

Copy the items from the set into the specified array

Parameters

param array

Array to copy to

param index

Index into the array to start

method Set<OrdA, A> Append (Set<OrdA, A> rhs) Source #

Add operator - performs a union of the two sets

Parameters

param rhs

Right hand side set

returns

Unioned set

method Set<OrdA, A> Subtract (Set<OrdA, A> rhs) Source #

Subtract operator - performs a subtract of the two sets

Parameters

param rhs

Right hand side set

returns

Subtracted set

method bool Equals (Set<OrdA, A> other) Source #

Equality test

Parameters

param other

Other set to test

returns

True if sets are equal

method bool Equals (object? obj) Source #

Equality override

method int GetHashCode () Source #

Get the hash code. Calculated from all items in the set.

The hash-code is cached after the first read.

method string ToString () Source #

method Seq<A> ToSeq () Source #

method EnumerableM<A> AsEnumerable () Source #

method Set<OrdA, A> Where (Func<A, bool> pred) Source #

method Set<OrdB, B> Bind <OrdB, B> (Func<A, Set<OrdB, B>> f) Source #

where OrdB : Ord<B>

method Set<OrdA, A> Bind (Func<A, Set<OrdA, A>> f) Source #

method EnumerableM<A> Skip (int amount) Source #

method int CompareTo (Set<OrdA, A> other) Source #

method Set<OrdA, A> Slice (A keyFrom, A keyTo) Source #

Creates a new map from a range/slice of this map

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Operators

operator + (Set<OrdA, A> lhs, Set<OrdA, A> rhs) Source #

Add operator - performs a union of the two sets

Parameters

param lhs

Left hand side set

param rhs

Right hand side set

returns

Unioned set

operator - (Set<OrdA, A> lhs, Set<OrdA, A> rhs) Source #

Subtract operator - performs a subtract of the two sets

Parameters

param lhs

Left hand side set

param rhs

Right hand side set

returns

Subtracted set

operator == (Set<OrdA, A> lhs, Set<OrdA, A> rhs) Source #

Equality operator

Parameters

param lhs

Left hand side set

param rhs

Right hand side set

returns

True if the two sets are equal

operator != (Set<OrdA, A> lhs, Set<OrdA, A> rhs) Source #

Non-equality operator

Parameters

param lhs

Left hand side set

param rhs

Right hand side set

returns

True if the two sets are equal

operator < (Set<OrdA, A> lhs, Set<OrdA, A> rhs) Source #

operator <= (Set<OrdA, A> lhs, Set<OrdA, A> rhs) Source #

operator > (Set<OrdA, A> lhs, Set<OrdA, A> rhs) Source #

operator >= (Set<OrdA, A> lhs, Set<OrdA, A> rhs) Source #

class Set Source #

Immutable set module AVL tree implementation AVL tree is a self-balancing binary search tree. http://en.wikipedia.org/wiki/AVL_tree

Methods

method bool isEmpty <OrdT, T> (Set<OrdT, T> set) Source #

where OrdT : Ord<T>

True if the set has no elements

Parameters

type T

Element type

returns

True if the set has no elements

method Set<OrdA, A> singleton <OrdA, A> (A value) Source #

where OrdA : Ord<A>

Create a new single item set

Parameters

type A

Element type

returns

Singleton set

method Set<OrdT, T> create <OrdT, T> () Source #

where OrdT : Ord<T>

Create a new empty set

Parameters

type T

Element type

returns

Empty set

method Set<OrdT, T> createRange <OrdT, T> (IEnumerable<T> range) Source #

where OrdT : Ord<T>

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

Parameters

type T

Element type

param range

Range of items

returns

Set

method Set<OrdA, A> createRange <OrdA, A> (ReadOnlySpan<A> range) Source #

where OrdA : Ord<A>

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

Parameters

type T

Element type

param range

Range of items

returns

Set

method Set<OrdT, T> empty <OrdT, T> () Source #

where OrdT : Ord<T>

Create a new empty set

Parameters

type T

Element type

returns

Empty set

method Set<OrdT, T> add <OrdT, T> (Set<OrdT, T> set, T value) Source #

where OrdT : Ord<T>

Add an item to the set

Parameters

type T

Element type

param set

Set to add item to

param value

Value to add to the set

returns

New set with the item added

method Set<OrdT, T> tryAdd <OrdT, T> (Set<OrdT, T> set, T value) Source #

where OrdT : Ord<T>

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

Parameters

type T

Element type

param set

Set to add item to

param value

Value to add to the set

returns

New set with the item maybe added

method Set<OrdT, T> addOrUpdate <OrdT, T> (Set<OrdT, T> set, T value) Source #

where OrdT : Ord<T>

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

Parameters

type T

Element type

param set

Set to add item to

param value

Value to add to the set

returns

New set with the item maybe added

method Set<OrdT, T> addRange <OrdT, T> (Set<OrdT, T> set, IEnumerable<T> range) Source #

where OrdT : Ord<T>

Atomically adds a range of items to the set.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Set<OrdT, T> tryAddRange <OrdT, T> (Set<OrdT, T> set, IEnumerable<T> range) Source #

where OrdT : Ord<T>

Atomically adds a range of items to the set. If an item already exists, it's ignored.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Set<OrdT, T> addOrUpdateRange <OrdT, T> (Set<OrdT, T> set, IEnumerable<T> range) Source #

where OrdT : Ord<T>

Atomically adds a range of items to the set. If an item already exists then replace it.

Null is not allowed for a Key

Parameters

param range

Range of keys to add

returns

New Set with the items added

method Option<T> find <OrdT, T> (Set<OrdT, T> set, T value) Source #

where OrdT : Ord<T>

Attempts to find an item in the set.

Parameters

type T

Element type

param set

Set

param value

Value to find

returns

Some(T) if found, None otherwise

method bool exists <OrdT, T> (Set<OrdT, T> set, Func<T, bool> pred) Source #

where OrdT : Ord<T>

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

Note this scans the entire set.

Parameters

type T

Element type

param set

Set

param pred

Predicate

returns

True if predicate returns true for any item

method bool equals <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

Returns true if both sets contain the same elements

method int length <OrdT, T> (Set<OrdT, T> set) Source #

where OrdT : Ord<T>

Get the number of elements in the set

Parameters

type T

Element type

param set

Set

returns

Number of elements

method Set<OrdT, T> subtract <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

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

method Set<OrdT, T> union <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

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

Parameters

type T

Element type

param setA

Set A

param setB

Set A

returns

A set which contains all items from both sets

method Set<OrdT, T> filter <OrdT, T> (Set<OrdT, T> set, Func<T, bool> pred) Source #

where OrdT : Ord<T>

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

type T

Element type

param set

Set

param pred

Predicate

returns

Filtered enumerable

method S fold <OrdT, T, S> (Set<OrdT, T> set, S state, Func<S, T, S> folder) Source #

where OrdT : Ord<T>

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

type S

State type

type T

Set element type

param set

Set to fold

param state

Initial state

param folder

Fold function

returns

Aggregate value

method S foldBack <OrdT, T, S> (Set<OrdT, T> set, S state, Func<S, T, S> folder) Source #

where OrdT : Ord<T>

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

type S

State type

type T

Set element type

param set

Set to fold

param state

Initial state

param folder

Fold function

returns

Aggregate value

method Set<OrdT, T> intersect <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

Returns the elements that are in both setA and setB

method Set<OrdT, T> except <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

Returns this - other. Only the items in this that are not in other will be returned.

method Set<OrdT, T> symmetricExcept <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

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

method Set<OrdR, R> map <OrdT, OrdR, T, R> (Set<OrdT, T> set, Func<T, R> mapper) Source #

where OrdT : Ord<T>
where OrdR : Ord<R>

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

Parameters

type T

Element type

type R

Mapped element type

param set

Set

param mapper

Mapping function

returns

Mapped enumerable

method Set<OrdT, T> map <OrdT, T> (Set<OrdT, T> set, Func<T, T> mapper) Source #

where OrdT : Ord<T>

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

Parameters

type T

Element type

type R

Mapped element type

param set

Set

param mapper

Mapping function

returns

Mapped enumerable

method bool contains <OrdT, T> (Set<OrdT, T> set, T value) Source #

where OrdT : Ord<T>

Returns True if the value is in the set

Parameters

type T

Element type

param set

Set

param value

Value to check

returns

True if the item 'value' is in the Set 'set'

method Set<OrdT, T> remove <OrdT, T> (Set<OrdT, T> set, T value) Source #

where OrdT : Ord<T>

Removes an item from the set (if it exists)

Parameters

type T

Element type

param set

Set

param value

Value to check

returns

New set with item removed

method bool isSubset <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

Returns True if setB is a subset of setA

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True is setB is a subset of setA

method bool isSuperset <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

Returns True if setB is a superset of setA

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True is setB is a superset of setA

method bool isProperSubset <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

Returns True if setB is a proper subset of setA

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True is setB is a proper subset of setA

method bool isProperSuperset <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

Returns True if setB is a proper superset of setA

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True is setB is a proper subset of setA

method bool overlaps <OrdT, T> (Set<OrdT, T> setA, Set<OrdT, T> setB) Source #

where OrdT : Ord<T>

Returns True if setA overlaps setB

Parameters

type T

Element type

param setA

Set A

param setB

Set B

returns

True if setA overlaps setB