Enhanced C#
Language of your choice: library documentation
Nested classes | Public fields | Public static fields | Properties | Public Member Functions | Static Public Member Functions | List of all members
Loyc.Collections.Set< T > Struct Template Reference

An immutable set. More...


Source file:
Inheritance diagram for Loyc.Collections.Set< T >:
Loyc.Collections.ISetImm< T >

Remarks

An immutable set.

This is the immutable version of MSet<T>. It does not allow changes to the set, but it provides operators (&, |, ^, -) for intersecting, merging, and subtracting sets, and it can be converted to a mutable MSet<T> in O(1) time. You can also add single items to the set using operators + and -.

For more information, please read the documentation of Set<T> and Impl.InternalSet<T>.

Performance warning: GetHashCode() XORs the hashcodes of all items in the set, while Equals() is a synonym for SetEquals(). Be aware that these methods are very slow for large sets.

Nested classes

struct  Enumerator
 Enumerator for MSet<T>. More...
 

Public fields

IEqualityComparer< T > _comparer
 
int _count
 

Public static fields

static readonly Set< T > Empty = new Set<T>()
 

Properties

bool IsEmpty [get]
 
InternalSet< T > InternalSet [get]
 
IEqualityComparer< T > Comparer [get]
 
int Count [get]
 
bool IsReadOnly [get]
 
bool ISetImm< T, Set< T > >. IsInverted [get]
 

Public Member Functions

 Set (IEnumerable< T > list)
 
 Set (IEqualityComparer< T > comparer)
 
 Set (IEnumerable< T > list, IEqualityComparer< T > comparer)
 
 Set (InternalSet< T > set, IEqualityComparer< T > comparer)
 
bool IEquatable< Set< T > >. Equals (Set< T > rhs)
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
bool Find (ref T item)
 
bool Contains (T item)
 
void CopyTo (T[] array, int arrayIndex)
 
Enumerator GetEnumerator ()
 
void ICollection< T >. Add (T item)
 
void ICollection< T >. Clear ()
 
bool ICollection< T >. Remove (T item)
 
IEnumerator< T > IEnumerable< T >. GetEnumerator ()
 
System.Collections.IEnumerator System.Collections.IEnumerable. GetEnumerator ()
 
bool IsSubsetOf (IEnumerable< T > other)
 Returns true if all items in this set are present in the other set. More...
 
bool IsSubsetOf (Set< T > other)
 
bool IsSubsetOf (MSet< T > other)
 
bool IsSubsetOf (ISet< T > other)
 
bool IsSupersetOf (IEnumerable< T > other)
 Returns true if all items in the other set are present in this set. More...
 
bool IsSupersetOf (Set< T > other)
 
bool IsSupersetOf (MSet< T > other)
 
bool Overlaps (IEnumerable< T > other)
 Returns true if this set contains at least one item from 'other'. More...
 
bool Overlaps (Set< T > other)
 
bool Overlaps (MSet< T > other)
 
bool IsProperSubsetOf (Set< T > other)
 
bool IsProperSubsetOf (MSet< T > other)
 
bool IsProperSubsetOf (ISet< T > other)
 
bool IsProperSubsetOf (IEnumerable< T > other)
 
bool IsProperSupersetOf (Set< T > other)
 
bool IsProperSupersetOf (MSet< T > other)
 
bool IsProperSupersetOf (ISet< T > other)
 
bool IsProperSupersetOf (IEnumerable< T > other)
 
bool SetEquals (Set< T > other)
 
bool SetEquals (MSet< T > other)
 
bool SetEquals (ISet< T > other)
 
bool SetEquals (IEnumerable< T > other)
 
ISetImm< T > ISetOperations< T, IEnumerable< T >, ISetImm< T > >. With (T item)
 
ISetImm< T > ISetOperations< T, IEnumerable< T >, ISetImm< T > >. Without (T item)
 
ISetImm< T > ISetOperations< T, IEnumerable< T >, ISetImm< T > >. Union (IEnumerable< T > other)
 
ISetImm< T > ISetOperations< T, IEnumerable< T >, ISetImm< T > >. Intersect (IEnumerable< T > other)
 
ISetImm< T > ISetOperations< T, IEnumerable< T >, ISetImm< T > >. Except (IEnumerable< T > other)
 
ISetImm< T > ISetOperations< T, IEnumerable< T >, ISetImm< T > >. Xor (IEnumerable< T > other)
 
Set< T > With (T item)
 
Set< T > Without (T item)
 
Set< T > WithToggled (T item)
 
Set< T > Union (Set< T > other)
 
Set< T > Union (Set< T > other, bool replaceWithValuesFromOther)
 
Set< T > Union (MSet< T > other, bool replaceWithValuesFromOther=false)
 
Set< T > Union (IEnumerable< T > other, bool replaceWithValuesFromOther=false)
 
Set< T > Intersect (Set< T > other)
 
Set< T > Intersect (MSet< T > other)
 
Set< T > Intersect (IEnumerable< T > other)
 
Set< T > Except (Set< T > other)
 
Set< T > Except (MSet< T > other)
 
Set< T > Except (IEnumerable< T > other)
 
Set< T > Xor (Set< T > other)
 
Set< T > Xor (MSet< T > other)
 
Set< T > Xor (IEnumerable< T > other)
 
MSet< T > AsMutable ()
 
Set< T > Where (Predicate< T > match)
 Returns a new set that contains only items that match the specified predicate (i.e. for which the predicate returns true). More...
 
long CountMemory (int sizeOfT)
 Measures the total size of all objects allocated to this collection, in bytes, including the size of this object itself; see Impl.InternalSet<T>.CountMemory. More...
 

Static Public Member Functions

static Set< T > operator& (Set< T > a, Set< T > b)
 
static Set< T > operator& (Set< T > a, MSet< T > b)
 
static Set< T > operator| (Set< T > a, Set< T > b)
 
static Set< T > operator| (Set< T > a, MSet< T > b)
 
static Set< T > operator- (Set< T > a, Set< T > b)
 
static Set< T > operator- (Set< T > a, MSet< T > b)
 
static Set< T > operator^ (Set< T > a, Set< T > b)
 
static Set< T > operator^ (Set< T > a, MSet< T > b)
 
static Set< T > operator+ (T item, Set< T > a)
 
static Set< T > operator+ (Set< T > a, T item)
 
static Set< T > operator- (Set< T > a, T item)
 
static Set< T > operator^ (Set< T > a, T item)
 
static operator MSet< T > (Set< T > a)
 

Member Function Documentation

long Loyc.Collections.Set< T >.CountMemory ( int  sizeOfT)
inline

Measures the total size of all objects allocated to this collection, in bytes, including the size of this object itself; see Impl.InternalSet<T>.CountMemory.

Referenced by Loyc.Collections.Set< Loyc.LLParserGenerator.AndPred >.CountMemory().

bool Loyc.Collections.Set< T >.IsSubsetOf ( IEnumerable< T >  other)
inline

Returns true if all items in this set are present in the other set.

Referenced by Loyc.Collections.Set< Loyc.LLParserGenerator.AndPred >.IsSubsetOf().

bool Loyc.Collections.Set< T >.IsSupersetOf ( IEnumerable< T >  other)
inline

Returns true if all items in the other set are present in this set.

Referenced by Loyc.Collections.Set< Loyc.LLParserGenerator.AndPred >.IsSupersetOf().

bool Loyc.Collections.Set< T >.Overlaps ( IEnumerable< T >  other)
inline

Returns true if this set contains at least one item from 'other'.

Referenced by Loyc.Collections.Set< Loyc.LLParserGenerator.AndPred >.Overlaps().

Set<T> Loyc.Collections.Set< T >.Where ( Predicate< T >  match)
inline

Returns a new set that contains only items that match the specified predicate (i.e. for which the predicate returns true).