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 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 (IEnumerable<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 <B> (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 IEnumerable<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 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<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 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 (System.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> Append (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 elipsis 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 IEnumerable<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 IEnumerable<A> Skip (int amount) Source #

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

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

where OrdA : struct, 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 TAccumulate Aggregate <TSource, TAccumulate> (this Set<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func) Source #

Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.

method TResult Aggregate <TSource, TAccumulate, TResult> (this Set<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector) Source #

Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.

method TSource Aggregate <TSource> (this Set<TSource> source, Func<TSource, TSource, TSource> func) Source #

Applies an accumulator function over a sequence.

method bool All <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Determines whether all elements of a sequence satisfy a condition.

method bool Any <TSource> (this Set<TSource> source) Source #

Determines whether a sequence contains any elements.

method bool Any <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Determines whether any element of a sequence satisfies a condition.

method IEnumerable<TSource> AsEnumerable <TSource> (this Set<TSource> source) Source #

Returns the input typed as IEnumerable.

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

Converts a generic IEnumerable to a generic IQueryable.

method decimal Average (this Set<decimal> source) Source #

Computes the average of a sequence of Decimal values.

method decimal Average <TSource> (this Set<TSource> source, Func<TSource, decimal> selector) Source #

Computes the average of a sequence of Decimal values that are obtained by invoking a transform function on each element of the input sequence.

method decimal? Average (this Set<decimal?> source) Source #

Computes the average of a sequence of nullable Decimal values.

method decimal? Average <TSource> (this Set<TSource> source, Func<TSource, decimal?> selector) Source #

Computes the average of a sequence of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence.

method double Average (this Set<double> source) Source #

Computes the average of a sequence of Double values.

method double Average (this Set<int> source) Source #

Computes the average of a sequence of Int32 values.

method double Average (this Set<long> source) Source #

Computes the average of a sequence of Int64 values.

method double Average <TSource> (this Set<TSource> source, Func<TSource, double> selector) Source #

Computes the average of a sequence of Double values that are obtained by invoking a transform function on each element of the input sequence.

method double Average <TSource> (this Set<TSource> source, Func<TSource, int> selector) Source #

Computes the average of a sequence of Int32 values that are obtained by invoking a transform function on each element of the input sequence.

method double Average <TSource> (this Set<TSource> source, Func<TSource, long> selector) Source #

Computes the average of a sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence.

method double? Average (this Set<double?> source) Source #

Computes the average of a sequence of nullable Double values.

method double? Average (this Set<int?> source) Source #

Computes the average of a sequence of nullable Int32 values.

method double? Average (this Set<long?> source) Source #

Computes the average of a sequence of nullable Int64 values.

method double? Average <TSource> (this Set<TSource> source, Func<TSource, double?> selector) Source #

Computes the average of a sequence of nullable Double values that are obtained by invoking a transform function on each element of the input sequence.

method double? Average <TSource> (this Set<TSource> source, Func<TSource, int?> selector) Source #

Computes the average of a sequence of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence.

method double? Average <TSource> (this Set<TSource> source, Func<TSource, long?> selector) Source #

Computes the average of a sequence of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence.

method float Average (this Set<float> source) Source #

Computes the average of a sequence of Single values.

method float Average <TSource> (this Set<TSource> source, Func<TSource, float> selector) Source #

Computes the average of a sequence of Single values that are obtained by invoking a transform function on each element of the input sequence.

method float? Average (this Set<float?> source) Source #

Computes the average of a sequence of nullable Single values.

method float? Average <TSource> (this Set<TSource> source, Func<TSource, float?> selector) Source #

Computes the average of a sequence of nullable Single values that are obtained by invoking a transform function on each element of the input sequence.

method IEnumerable<TSource> Concat <TSource> (this Set<TSource> first, IEnumerable<TSource> second) Source #

Concatenates two sequences.

method bool Contains <TSource> (this Set<TSource> source, TSource value) Source #

Determines whether a sequence contains a specified element by using the default equality comparer.

method bool Contains <TSource> (this Set<TSource> source, TSource value, IEqualityComparer<TSource> comparer) Source #

Determines whether a sequence contains a specified element by using a specified IEqualityComparer.

method int Count <TSource> (this Set<TSource> source) Source #

Returns the number of elements in a sequence.

method int Count <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns a number that represents how many elements in the specified sequence satisfy a condition.

method IEnumerable<TSource> DefaultIfEmpty <TSource> (this Set<TSource> source) Source #

Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.

method IEnumerable<TSource> DefaultIfEmpty <TSource> (this Set<TSource> source, TSource defaultValue) Source #

Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.

method IEnumerable<TSource> Distinct <TSource> (this Set<TSource> source) Source #

Returns distinct elements from a sequence by using the default equality comparer to compare values.

method IEnumerable<TSource> Distinct <TSource> (this Set<TSource> source, IEqualityComparer<TSource> comparer) Source #

Returns distinct elements from a sequence by using a specified IEqualityComparer to compare values.

method TSource ElementAt <TSource> (this Set<TSource> source, int index) Source #

Returns the element at a specified index in a sequence.

method TSource ElementAtOrDefault <TSource> (this Set<TSource> source, int index) Source #

Returns the element at a specified index in a sequence or a default value if the index is out of range.

method IEnumerable<TSource> Except <TSource> (this Set<TSource> first, IEnumerable<TSource> second) Source #

Produces the set difference of two sequences by using the default equality comparer to compare values.

method IEnumerable<TSource> Except <TSource> (this Set<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer) Source #

Produces the set difference of two sequences by using the specified IEqualityComparer to compare values.

method TSource First <TSource> (this Set<TSource> source) Source #

Returns the first element of a sequence.

method TSource First <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns the first element in a sequence that satisfies a specified condition.

method TSource FirstOrDefault <TSource> (this Set<TSource> source) Source #

Returns the first element of a sequence, or a default value if the sequence contains no elements.

method TSource FirstOrDefault <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.

method IEnumerable<IGrouping<TKey, TElement>> GroupBy <TSource, TKey, TElement> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) Source #

Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

method IEnumerable<IGrouping<TKey, TElement>> GroupBy <TSource, TKey, TElement> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer) Source #

Groups the elements of a sequence according to a key selector function. The keys are compared by using a comparer and each group's elements are projected by using a specified function.

method IEnumerable<IGrouping<TKey, TSource>> GroupBy <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector) Source #

Groups the elements of a sequence according to a specified key selector function.

method IEnumerable<IGrouping<TKey, TSource>> GroupBy <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) Source #

Groups the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.

method IEnumerable<TResult> GroupBy <TSource, TKey, TElement, TResult> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector) Source #

Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function.

method IEnumerable<TResult> GroupBy <TSource, TKey, TElement, TResult> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer) Source #

Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function.

method IEnumerable<TResult> GroupBy <TSource, TKey, TResult> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector) Source #

Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.

method IEnumerable<TResult> GroupBy <TSource, TKey, TResult> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer) Source #

Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The keys are compared by using a specified comparer.

method IEnumerable<TResult> GroupJoin <TOuter, TInner, TKey, TResult> (this Set<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector) Source #

Correlates the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys.

method IEnumerable<TResult> GroupJoin <TOuter, TInner, TKey, TResult> (this Set<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer) Source #

Correlates the elements of two sequences based on key equality and groups the results. A specified IEqualityComparer is used to compare keys.

method IEnumerable<TSource> Intersect <TSource> (this Set<TSource> first, IEnumerable<TSource> second) Source #

Produces the set intersection of two sequences by using the default equality comparer to compare values.

method IEnumerable<TSource> Intersect <TSource> (this Set<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer) Source #

Produces the set intersection of two sequences by using the specified IEqualityComparer to compare values.

method IEnumerable<TResult> Join <TOuter, TInner, TKey, TResult> (this Set<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector) Source #

Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys.

method IEnumerable<TResult> Join <TOuter, TInner, TKey, TResult> (this Set<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer) Source #

Correlates the elements of two sequences based on matching keys. A specified IEqualityComparer is used to compare keys.

method TSource Last <TSource> (this Set<TSource> source) Source #

Returns the last element of a sequence.

method TSource Last <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns the last element of a sequence that satisfies a specified condition.

method TSource LastOrDefault <TSource> (this Set<TSource> source) Source #

Returns the last element of a sequence, or a default value if the sequence contains no elements.

method TSource LastOrDefault <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.

method long LongCount <TSource> (this Set<TSource> source) Source #

Returns an Int64 that represents the total number of elements in a sequence.

method long LongCount <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns an Int64 that represents how many elements in a sequence satisfy a condition.

method decimal Max (this Set<decimal> source) Source #

Returns the maximum value in a sequence of Decimal values.

method decimal Max <TSource> (this Set<TSource> source, Func<TSource, decimal> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum Decimal value.

method decimal? Max (this Set<decimal?> source) Source #

Returns the maximum value in a sequence of nullable Decimal values.

method decimal? Max <TSource> (this Set<TSource> source, Func<TSource, decimal?> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum nullable Decimal value.

method double Max (this Set<double> source) Source #

Returns the maximum value in a sequence of Double values.

method double Max <TSource> (this Set<TSource> source, Func<TSource, double> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum Double value.

method double? Max (this Set<double?> source) Source #

Returns the maximum value in a sequence of nullable Double values.

method double? Max <TSource> (this Set<TSource> source, Func<TSource, double?> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum nullable Double value.

method float Max (this Set<float> source) Source #

Returns the maximum value in a sequence of Single values.

method float Max <TSource> (this Set<TSource> source, Func<TSource, float> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum Single value.

method float? Max (this Set<float?> source) Source #

Returns the maximum value in a sequence of nullable Single values.

method float? Max <TSource> (this Set<TSource> source, Func<TSource, float?> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum nullable Single value.

method int Max (this Set<int> source) Source #

Returns the maximum value in a sequence of Int32 values.

method int Max <TSource> (this Set<TSource> source, Func<TSource, int> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum Int32 value.

method int? Max (this Set<int?> source) Source #

Returns the maximum value in a sequence of nullable Int32 values.

method int? Max <TSource> (this Set<TSource> source, Func<TSource, int?> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum nullable Int32 value.

method long Max (this Set<long> source) Source #

Returns the maximum value in a sequence of Int64 values.

method long Max <TSource> (this Set<TSource> source, Func<TSource, long> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum Int64 value.

method long? Max (this Set<long?> source) Source #

Returns the maximum value in a sequence of nullable Int64 values.

method long? Max <TSource> (this Set<TSource> source, Func<TSource, long?> selector) Source #

Invokes a transform function on each element of a sequence and returns the maximum nullable Int64 value.

method TResult Max <TSource, TResult> (this Set<TSource> source, Func<TSource, TResult> selector) Source #

Invokes a transform function on each element of a generic sequence and returns the maximum resulting value.

method TSource Max <TSource> (this Set<TSource> source) Source #

Returns the maximum value in a generic sequence.

method decimal Min (this Set<decimal> source) Source #

Returns the minimum value in a sequence of Decimal values.

method decimal Min <TSource> (this Set<TSource> source, Func<TSource, decimal> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum Decimal value.

method decimal? Min (this Set<decimal?> source) Source #

Returns the minimum value in a sequence of nullable Decimal values.

method decimal? Min <TSource> (this Set<TSource> source, Func<TSource, decimal?> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum nullable Decimal value.

method double Min (this Set<double> source) Source #

Returns the minimum value in a sequence of Double values.

method double Min <TSource> (this Set<TSource> source, Func<TSource, double> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum Double value.

method double? Min (this Set<double?> source) Source #

Returns the minimum value in a sequence of nullable Double values.

method double? Min <TSource> (this Set<TSource> source, Func<TSource, double?> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum nullable Double value.

method float Min (this Set<float> source) Source #

Returns the minimum value in a sequence of Single values.

method float Min <TSource> (this Set<TSource> source, Func<TSource, float> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum Single value.

method float? Min (this Set<float?> source) Source #

Returns the minimum value in a sequence of nullable Single values.

method float? Min <TSource> (this Set<TSource> source, Func<TSource, float?> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum nullable Single value.

method int Min (this Set<int> source) Source #

Returns the minimum value in a sequence of Int32 values.

method int Min <TSource> (this Set<TSource> source, Func<TSource, int> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum Int32 value.

method int? Min (this Set<int?> source) Source #

Returns the minimum value in a sequence of nullable Int32 values.

method int? Min <TSource> (this Set<TSource> source, Func<TSource, int?> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum nullable Int32 value.

method long Min (this Set<long> source) Source #

Returns the minimum value in a sequence of Int64 values.

method long Min <TSource> (this Set<TSource> source, Func<TSource, long> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum Int64 value.

method long? Min (this Set<long?> source) Source #

Returns the minimum value in a sequence of nullable Int64 values.

method long? Min <TSource> (this Set<TSource> source, Func<TSource, long?> selector) Source #

Invokes a transform function on each element of a sequence and returns the minimum nullable Int64 value.

method TResult Min <TSource, TResult> (this Set<TSource> source, Func<TSource, TResult> selector) Source #

Invokes a transform function on each element of a generic sequence and returns the minimum resulting value.

method TSource Min <TSource> (this Set<TSource> source) Source #

Returns the minimum value in a generic sequence.

method IOrderedEnumerable<TSource> OrderBy <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector) Source #

Sorts the elements of a sequence in ascending order according to a key.

method IOrderedEnumerable<TSource> OrderBy <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer) Source #

Sorts the elements of a sequence in ascending order by using a specified comparer.

method IOrderedEnumerable<TSource> OrderByDescending <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector) Source #

Sorts the elements of a sequence in descending order according to a key.

method IOrderedEnumerable<TSource> OrderByDescending <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer) Source #

Sorts the elements of a sequence in descending order by using a specified comparer.

method IEnumerable<TSource> Reverse <TSource> (this Set<TSource> source) Source #

Inverts the order of the elements in a sequence.

method bool SequenceEqual <TSource> (this Set<TSource> first, IEnumerable<TSource> second) Source #

Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.

method bool SequenceEqual <TSource> (this Set<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer) Source #

Determines whether two sequences are equal by comparing their elements by using a specified IEqualityComparer.

method TSource Single <TSource> (this Set<TSource> source) Source #

Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.

method TSource Single <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.

method TSource SingleOrDefault <TSource> (this Set<TSource> source) Source #

Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

method TSource SingleOrDefault <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

method IEnumerable<TSource> Skip <TSource> (this Set<TSource> source, int count) Source #

Bypasses a specified number of elements in a sequence and then returns the remaining elements.

method IEnumerable<TSource> SkipWhile <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.

method IEnumerable<TSource> SkipWhile <TSource> (this Set<TSource> source, Func<TSource, int, bool> predicate) Source #

Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function.

method decimal Sum (this Set<decimal> source) Source #

Computes the sum of a sequence of Decimal values.

method decimal Sum <TSource> (this Set<TSource> source, Func<TSource, decimal> selector) Source #

Computes the sum of the sequence of Decimal values that are obtained by invoking a transform function on each element of the input sequence.

method decimal? Sum (this Set<decimal?> source) Source #

Computes the sum of a sequence of nullable Decimal values.

method decimal? Sum <TSource> (this Set<TSource> source, Func<TSource, decimal?> selector) Source #

Computes the sum of the sequence of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence.

method double Sum (this Set<double> source) Source #

Computes the sum of a sequence of Double values.

method double Sum <TSource> (this Set<TSource> source, Func<TSource, double> selector) Source #

Computes the sum of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence.

method double? Sum (this Set<double?> source) Source #

Computes the sum of a sequence of nullable Double values.

method double? Sum <TSource> (this Set<TSource> source, Func<TSource, double?> selector) Source #

Computes the sum of the sequence of nullable Double values that are obtained by invoking a transform function on each element of the input sequence.

method float Sum (this Set<float> source) Source #

Computes the sum of a sequence of Single values.

method float Sum <TSource> (this Set<TSource> source, Func<TSource, float> selector) Source #

Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence.

method float? Sum (this Set<float?> source) Source #

Computes the sum of a sequence of nullable Single values.

method float? Sum <TSource> (this Set<TSource> source, Func<TSource, float?> selector) Source #

Computes the sum of the sequence of nullable Single values that are obtained by invoking a transform function on each element of the input sequence.

method int Sum (this Set<int> source) Source #

Computes the sum of a sequence of Int32 values.

method int Sum <TSource> (this Set<TSource> source, Func<TSource, int> selector) Source #

Computes the sum of the sequence of Int32 values that are obtained by invoking a transform function on each element of the input sequence.

method int? Sum (this Set<int?> source) Source #

Computes the sum of a sequence of nullable Int32 values.

method int? Sum <TSource> (this Set<TSource> source, Func<TSource, int?> selector) Source #

Computes the sum of the sequence of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence.

method long Sum (this Set<long> source) Source #

Computes the sum of a sequence of Int64 values.

method long Sum <TSource> (this Set<TSource> source, Func<TSource, long> selector) Source #

Computes the sum of the sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence.

method long? Sum (this Set<long?> source) Source #

Computes the sum of a sequence of nullable Int64 values.

method long? Sum <TSource> (this Set<TSource> source, Func<TSource, long?> selector) Source #

Computes the sum of the sequence of nullable Int64 values that are obtained by invoking a transform function on each element of the input sequence.

method IEnumerable<TSource> Take <TSource> (this Set<TSource> source, int count) Source #

Returns a specified number of contiguous elements from the start of a sequence.

method IEnumerable<TSource> TakeWhile <TSource> (this Set<TSource> source, Func<TSource, bool> predicate) Source #

Returns elements from a sequence as long as a specified condition is true.

method IEnumerable<TSource> TakeWhile <TSource> (this Set<TSource> source, Func<TSource, int, bool> predicate) Source #

Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

method TSource[] ToArray <TSource> (this Set<TSource> source) Source #

Creates an array from a IEnumerable.

method Dictionary<TKey, TElement> ToDictionary <TSource, TKey, TElement> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) Source #

Creates a Dictionary<TKey,TValue> from an IEnumerable according to specified key selector and element selector functions.

method Dictionary<TKey, TElement> ToDictionary <TSource, TKey, TElement> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer) Source #

Creates a Dictionary<TKey,TValue> from an IEnumerable according to a specified key selector function, a comparer, and an element selector function.

method Dictionary<TKey, TSource> ToDictionary <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector) Source #

Creates a Dictionary<TKey,TValue> from an IEnumerable according to a specified key selector function.

method Dictionary<TKey, TSource> ToDictionary <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) Source #

Creates a Dictionary<TKey,TValue> from an IEnumerable according to a specified key selector function and key comparer.

method List<TSource> ToList <TSource> (this Set<TSource> source) Source #

Creates a List from an IEnumerable.

method ILookup<TKey, TElement> ToLookup <TSource, TKey, TElement> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) Source #

Creates a Lookup<TKey,TElement> from an IEnumerable according to specified key selector and element selector functions.

method ILookup<TKey, TElement> ToLookup <TSource, TKey, TElement> (this Set<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer) Source #

Creates a Lookup<TKey,TElement> from an IEnumerable according to a specified key selector function, a comparer and an element selector function.

method ILookup<TKey, TSource> ToLookup <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector) Source #

Creates a Lookup<TKey,TElement> from an IEnumerable according to a specified key selector function.

method ILookup<TKey, TSource> ToLookup <TSource, TKey> (this Set<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) Source #

Creates a Lookup<TKey,TElement> from an IEnumerable according to a specified key selector function and key comparer.

method IEnumerable<TSource> Union <TSource> (this Set<TSource> first, IEnumerable<TSource> second) Source #

Produces the set union of two sequences by using the default equality comparer.

method IEnumerable<TSource> Union <TSource> (this Set<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer) Source #

Produces the set union of two sequences by using a specified IEqualityComparer.

method IEnumerable<TResult> Zip <TFirst, TSecond, TResult> (this Set<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector) Source #

Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.

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 #

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 <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<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<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

struct Set <OrdA, A> Source #

where OrdA : struct, 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 (IEnumerable<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 IEnumerable<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 : struct, 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 (System.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 IEnumerable<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 : struct, Ord<B>

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

method IEnumerable<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

Subtractd 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 : struct, Ord<T>

True if the set has no elements

Parameters

type T

Element type

returns

True if the set has no elements

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

where OrdT : struct, 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 : struct, 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<OrdT, T> empty <OrdT, T> () Source #

where OrdT : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, Ord<T>

Returns true if both sets contain the same elements

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

where OrdT : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, Ord<T>
where OrdR : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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 : struct, 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