Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public static fields | Properties | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Loyc.Collections.InvertibleSet< T > Class Template Reference

An immutable set that can be inverted. For example, an InvertibleSet<int> could contain "everything except 4 and 10", or it could contain a positive set such as "1, 2, and 3". More...


Source file:
Inheritance diagram for Loyc.Collections.InvertibleSet< T >:
Loyc.Collections.ISetImm< T, SetT > Loyc.Collections.ISetOperations< in T, SetT > Loyc.Collections.ISetOperations< in T, in InSetT, out OutSetT >

Remarks

An immutable set that can be inverted. For example, an InvertibleSet<int> could contain "everything except 4 and 10", or it could contain a positive set such as "1, 2, and 3".

InvertibleSet is implemented as a normal Set{T} plus an IsInverted flag. The original (non-inverted) set can be retrieved from the BaseSet property

Note: this class is designed with the assumption that there are an infinite number of possible T objects, and under certain conditions the set-testing operations such as Equals() and IsSubsetOf() can return false when they should return true. For example, consider two sets of bytes: one set holds the numbers 0..100, and the other contains 101..255 but is marked as inverted. Arguably, Equals() and IsSubsetOf() should return true when comparing these sets, but they return false because they are unaware of the finite nature of a byte.

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.

Public static fields

static readonly InvertibleSet< T > Empty = new InvertibleSet<T>(Set<T>.Empty, false)
 
static readonly InvertibleSet< T > All = new InvertibleSet<T>(Set<T>.Empty, true)
 

Properties

Set< T > BaseSet [get]
 
bool IsInverted [get]
 
bool IsEmpty [get]
 
bool ContainsEverything [get]
 
- Properties inherited from Loyc.Collections.ISetImm< T, SetT >
bool IsInverted [get]
 Returns true if the set is inverted, which means that the enumerator returns all the items that are not in the set, and the IReadOnlyCollection{T}.Count returns the number of items that are not in the set. More...
 

Public Member Functions

 InvertibleSet (Set< T > set, bool inverted)
 
 InvertibleSet (IEnumerable< T > list, bool inverted=false)
 
 InvertibleSet (IEnumerable< T > list, IEqualityComparer< T > comparer, bool inverted=false)
 
InvertibleSet< T > Inverted ()
 
bool Contains (T item)
 
InvertibleSet< T > Without (T item)
 
InvertibleSet< T > With (T item)
 
InvertibleSet< T > Union (InvertibleSet< T > other)
 
InvertibleSet< T > Intersect (InvertibleSet< T > other)
 
InvertibleSet< T > Intersect (InvertibleSet< T > other, bool subtractOther)
 
InvertibleSet< T > Except (InvertibleSet< T > other)
 
InvertibleSet< T > Xor (InvertibleSet< T > other)
 
override int GetHashCode ()
 
override bool Equals (object obj)
 
bool IsSubsetOf (InvertibleSet< T > other)
 TODO NOT IMPLEMENTED Returns true if all items in this set are present in the other set. More...
 
bool IsSupersetOf (InvertibleSet< T > other)
 TODO NOT IMPLEMENTED Returns true if all items in the other set are present in this set. More...
 
bool Overlaps (InvertibleSet< T > other)
 TODO NOT IMPLEMENTED Returns true if this set contains at least one item from 'other'. More...
 
bool IsProperSubsetOf (InvertibleSet< T > other)
 
bool IsProperSupersetOf (InvertibleSet< T > other)
 
bool SetEquals (InvertibleSet< T > other)
 
- Public Member Functions inherited from Loyc.Collections.ISetOperations< in T, in InSetT, out OutSetT >
OutSetT Union (InSetT other)
 
OutSetT Intersect (InSetT other)
 
OutSetT Except (InSetT other)
 
OutSetT Xor (InSetT other)
 

Static Public Member Functions

static InvertibleSet< T > With (params T[] list)
 
static InvertibleSet< T > Without (params T[] list)
 

Protected Member Functions

InvertibleSet< T > With (T item, bool removed)
 

Member Function Documentation

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

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

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

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

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

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