Set<OrdA, A> Struct

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

DECLARATION
[Serializable]
public struct Set<OrdA, A> : IEnumerable<A>,
IEquatable<Set<OrdA, A>>
NAMESPACE
LanguageExt

Constructors

Set(IEnumerable<A>)
SUMMARY

Ctor from an enumerable

PARAMETERS
items
IEnumerable<A>
DECLARATION
public ctor Set(IEnumerable<A> items)

Fields

Empty
DECLARATION
public static readonly Set<OrdA, A> Empty

Properties

Count
SUMMARY

Number of items in the set

DECLARATION
[Pure]
public int Count { get; }
RETURNS
int
IsEmpty
SUMMARY

True if the set has no elements

DECLARATION
[Pure]
public bool IsEmpty { get; }
RETURNS
bool

Methods

Add(A)
SUMMARY

Add an item to the set

PARAMETERS
value
A
Value to add to the set
DECLARATION
[Pure]
public Set<OrdA, A> Add(A value)
RETURNS
Set<OrdA, A>
New set with the item added
AddOrUpdate(A)
SUMMARY

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

PARAMETERS
value
A
Value to add to the set
DECLARATION
[Pure]
public Set<OrdA, A> AddOrUpdate(A value)
RETURNS
Set<OrdA, A>
New set with the item maybe added
AddOrUpdateRange(IEnumerable<A>)
SUMMARY

Atomically adds a range of items to the set. If any items already exist, they're ignored.

PARAMETERS
range
IEnumerable<A>
Range of keys to add
REMARKS
Null is not allowed for a Key
DECLARATION
[Pure]
public Set<OrdA, A> AddOrUpdateRange(IEnumerable<A> range)
RETURNS
Set<OrdA, A>
New Set with the items added
EXCEPTIONS
ArgumentException
Throws ArgumentException if any of the keys already exist
ArgumentNullException
Throws ArgumentNullException if any of the keys are null
AddRange(IEnumerable<A>)
SUMMARY

Atomically adds a range of items to the set.

PARAMETERS
range
IEnumerable<A>
Range of keys to add
REMARKS
Null is not allowed for a Key
DECLARATION
[Pure]
public Set<OrdA, A> AddRange(IEnumerable<A> range)
RETURNS
Set<OrdA, A>
New Set with the items added
EXCEPTIONS
ArgumentException
Throws ArgumentException if any of the keys already exist
ArgumentNullException
Throws ArgumentNullException if any of the keys are null
Append(Set<OrdA, A>)
SUMMARY

Add operator - performs a union of the two sets

PARAMETERS
rhs
Set<OrdA, A>
Right hand side set
DECLARATION
[Pure]
public Set<OrdA, A> Append(Set<OrdA, A> rhs)
RETURNS
Set<OrdA, A>
Unioned set
AsEnumerable()
DECLARATION
[Pure]
public IEnumerable<A> AsEnumerable()
RETURNS
IEnumerable<A>
Bind(Func<A, Set<OrdA, A>>)
PARAMETERS
f
Func<A, Set<OrdA, A>>
DECLARATION
[Pure]
public Set<OrdA, A> Bind(Func<A, Set<OrdA, A>> f)
RETURNS
Set<OrdA, A>
Bind<OrdB, B>(Func<A, Set<OrdB, B>>)
PARAMETERS
f
Func<A, Set<OrdB, B>>
DECLARATION
[Pure]
public Set<OrdB, B> Bind<OrdB, B>(Func<A, Set<OrdB, B>> f)
RETURNS
Set<OrdB, B>
CONSTRAINTS
where OrdB : struct Ord<B>
Clear()
SUMMARY

Clears the set

DECLARATION
[Pure]
public Set<OrdA, A> Clear()
RETURNS
Set<OrdA, A>
An empty set
Contains(A)
SUMMARY

Returns True if the value is in the set

PARAMETERS
value
A
Value to check
DECLARATION
[Pure]
public bool Contains(A value)
RETURNS
bool
True if the item 'value' is in the Set 'set'
CopyTo(A, int)
SUMMARY

Copy the items from the set into the specified array

PARAMETERS
array
A
Array to copy to
index
int
Index into the array to start
DECLARATION
public void CopyTo(A array, int index)
CopyTo(System.Array, int)
SUMMARY

Copy the items from the set into the specified array

PARAMETERS
array
System.Array
Array to copy to
index
int
Index into the array to start
DECLARATION
public void CopyTo(System.Array array, int index)
Equals(Set<OrdA, A>)
SUMMARY

Equality test

PARAMETERS
other
Set<OrdA, A>
Other set to test
DECLARATION
[Pure]
public bool Equals(Set<OrdA, A> other)
RETURNS
bool
True if sets are equal
Equals(object)
SUMMARY

Equality override

PARAMETERS
obj
object
DECLARATION
[Pure]
public override bool Equals(object obj)
RETURNS
bool
Except(Set<OrdA, A>)
SUMMARY

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

PARAMETERS
other
Set<OrdA, A>
DECLARATION
[Pure]
public Set<OrdA, A> Except(Set<OrdA, A> other)
RETURNS
Set<OrdA, A>
Exists(Func<A, bool>)
SUMMARY

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

PARAMETERS
pred
Func<A, bool>
Predicate
REMARKS
Note this scans the entire set.
DECLARATION
[Pure]
public bool Exists(Func<A, bool> pred)
RETURNS
bool
True if predicate returns true for any item
Filter(Func<A, bool>)
SUMMARY

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

PARAMETERS
pred
Func<A, bool>
Predicate
DECLARATION
[Pure]
public Set<OrdA, A> Filter(Func<A, bool> pred)
RETURNS
Set<OrdA, A>
Filtered enumerable
Find(A)
SUMMARY

Attempts to find an item in the set.

PARAMETERS
value
A
Value to find
DECLARATION
[Pure]
public Option<A> Find(A value)
RETURNS
Option<A>
Some(T) if found, None otherwise
Fold<S>(S, Func<S, A, S>)
SUMMARY

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

PARAMETERS
state
S
Initial state
folder
Func<S, A, S>
Fold function
DECLARATION
[Pure]
public S Fold<S>(S state, Func<S, A, S> folder)
RETURNS
S
Aggregate value
FoldBack<S>(S, Func<S, A, S>)
SUMMARY

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

PARAMETERS
state
S
Initial state
folder
Func<S, A, S>
Fold function
DECLARATION
[Pure]
public S FoldBack<S>(S state, Func<S, A, S> folder)
RETURNS
S
Aggregate value
GetEnumerator()
SUMMARY

Get enumerator

DECLARATION
[Pure]
public IEnumerator<A> GetEnumerator()
RETURNS
IEnumerator<A>
IEnumerator T
GetHashCode()
SUMMARY

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

REMARKS
The hash-code is cached after the first read.
DECLARATION
[Pure]
public override int GetHashCode()
RETURNS
int
Intersect(Set<OrdA, A>)
SUMMARY

Returns the elements that are in both this and other

PARAMETERS
other
Set<OrdA, A>
DECLARATION
[Pure]
public Set<OrdA, A> Intersect(Set<OrdA, A> other)
RETURNS
Set<OrdA, A>
IsProperSubsetOf(Set<OrdA, A>)
SUMMARY

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

PARAMETERS
other
Set<OrdA, A>
DECLARATION
[Pure]
public bool IsProperSubsetOf(Set<OrdA, A> other)
RETURNS
bool
True if 'other' is a proper subset of this set
IsProperSupersetOf(Set<OrdA, A>)
SUMMARY

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

PARAMETERS
other
Set<OrdA, A>
DECLARATION
[Pure]
public bool IsProperSupersetOf(Set<OrdA, A> other)
RETURNS
bool
True if 'other' is a proper superset of this set
IsSubsetOf(Set<OrdA, A>)
SUMMARY

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

PARAMETERS
other
Set<OrdA, A>
DECLARATION
[Pure]
public bool IsSubsetOf(Set<OrdA, A> other)
RETURNS
bool
True if 'other' is a superset of this set
IsSupersetOf(Set<OrdA, A>)
SUMMARY

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

PARAMETERS
other
Set<OrdA, A>
DECLARATION
[Pure]
public bool IsSupersetOf(Set<OrdA, A> other)
RETURNS
bool
True if 'other' is a superset of this set
Length()
SUMMARY

Get the number of elements in the set

DECLARATION
[Pure]
public int Length()
RETURNS
int
Number of elements
Map(Func<A, A>)
SUMMARY

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

PARAMETERS
map
Func<A, A>
DECLARATION
[Pure]
public Set<OrdA, A> Map(Func<A, A> map)
RETURNS
Set<OrdA, A>
Mapped Set
Map<OrdB, B>(Func<A, B>)
SUMMARY

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

PARAMETERS
map
Func<A, B>
DECLARATION
[Pure]
public Set<OrdB, B> Map<OrdB, B>(Func<A, B> map)
RETURNS
Set<OrdB, B>
Mapped Set
CONSTRAINTS
where OrdB : struct Ord<B>
Overlaps(Set<OrdA, A>)
SUMMARY

Returns True if other overlaps this set

PARAMETERS
other
Set<OrdA, A>
DECLARATION
[Pure]
public bool Overlaps(Set<OrdA, A> other)
RETURNS
bool
True if other overlaps this set
Remove(A)
SUMMARY

Removes an item from the set (if it exists)

PARAMETERS
value
A
Value to check
DECLARATION
[Pure]
public Set<OrdA, A> Remove(A value)
RETURNS
Set<OrdA, A>
New set with item removed
SetEquals(Set<OrdA, A>)
SUMMARY

Returns true if both sets contain the same elements

PARAMETERS
other
Set<OrdA, A>
Other distinct set to compare
DECLARATION
[Pure]
public bool SetEquals(Set<OrdA, A> other)
RETURNS
bool
True if the sets are equal
Skip(int)
PARAMETERS
amount
int
DECLARATION
[Pure]
public IEnumerable<A> Skip(int amount)
RETURNS
IEnumerable<A>
Subtract(Set<OrdA, A>)
SUMMARY

Subtract operator - performs a subtract of the two sets

PARAMETERS
rhs
Set<OrdA, A>
Right hand side set
DECLARATION
[Pure]
public Set<OrdA, A> Subtract(Set<OrdA, A> rhs)
RETURNS
Set<OrdA, A>
Subtracted set
SymmetricExcept(Set<OrdA, A>)
SUMMARY

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

PARAMETERS
other
Set<OrdA, A>
DECLARATION
[Pure]
public Set<OrdA, A> SymmetricExcept(Set<OrdA, A> other)
RETURNS
Set<OrdA, A>
ToSeq()
DECLARATION
[Pure]
public Seq<A> ToSeq()
RETURNS
Seq<A>
ToString()
DECLARATION
[Pure]
public override string ToString()
RETURNS
string
TryAdd(A)
SUMMARY

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

PARAMETERS
value
A
Value to add to the set
DECLARATION
[Pure]
public Set<OrdA, A> TryAdd(A value)
RETURNS
Set<OrdA, A>
New set with the item maybe added
TryAddRange(IEnumerable<A>)
SUMMARY

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

PARAMETERS
range
IEnumerable<A>
Range of keys to add
REMARKS
Null is not allowed for a Key
DECLARATION
[Pure]
public Set<OrdA, A> TryAddRange(IEnumerable<A> range)
RETURNS
Set<OrdA, A>
New Set with the items added
EXCEPTIONS
ArgumentException
Throws ArgumentException if any of the keys already exist
ArgumentNullException
Throws ArgumentNullException if any of the keys are null
Union(Set<OrdA, A>)
SUMMARY

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

PARAMETERS
other
Set<OrdA, A>
Other set to union with
DECLARATION
[Pure]
public Set<OrdA, A> Union(Set<OrdA, A> other)
RETURNS
Set<OrdA, A>
A set which contains all items from both sets
Where(Func<A, bool>)
PARAMETERS
pred
Func<A, bool>
DECLARATION
[Pure]
public Set<OrdA, A> Where(Func<A, bool> pred)
RETURNS
Set<OrdA, A>