A mutable set.
This class is based on Impl.InternalSet{T}; see its documentation for technical details about the implementation.
Assuming T is a reference type, this class uses less memory than HashSet{T} and, under certain conditions, is faster. Specifically,
-
This class is optimized for objects whose Equals() and GetHashCode() methods are fast, or for which equality is synonymous with "reference
equality" so it is not necessary to call Equals() at all.
-
This class supports fast cloning and overloads the following operators to perform set operations: & (intersection), | (union), - (subtraction, i.e. ExceptWith) and ^ (xor, i.e. SymmetricExceptWith. These operators clone the left-hand argument, so they benefit from fast- cloning functionality.
This class may be slower than HashSet{T} if the comparison method for T is slow; up to four comparisons are required per add/remove operation.
You can convert MSet{T} to Set{T} and back in O(1) time using a C# cast operator.
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.
|
| MSet (IEnumerable< T > copy) |
|
| MSet (IEnumerable< T > copy, IEqualityComparer< T > comparer) |
|
| MSet (IEqualityComparer< T > comparer) |
|
| MSet (InternalSet< T > set, IEqualityComparer< T > comparer) |
|
void | AddUnique (T item) |
| Adds the specified item to the set, or throws an exception if a matching item is already present. More...
|
|
bool | Find (ref T item) |
| Searches for an item. If the item is found, the copy in the set is returned in the 'item' parameter. Note: there is no reason to call this method in a set of completely immutable; in such cases, call Contains instead. More...
|
|
bool | AddOrFind (ref T item, bool replaceIfPresent) |
| Adds the specified item to the set, and retrieves an existing copy of the item if one existed. Note: there is no reason to call this method in a set of singletons (e.g. Symbol) because if an item is found, it will always be the exact same object that you searched for. More...
|
|
bool | Add (T item, bool replaceIfPresent) |
| Adds the specified item to the set. More...
|
|
virtual MSet< T > | Clone () |
| Fast-clones the set in O(1) time. More...
|
|
override bool | Equals (object obj) |
|
override int | GetHashCode () |
|
bool | Add (T item) |
| Adds the specified item to the set if it is not present. More...
|
|
int | AddRange (IEnumerable< T > items) |
|
void | Clear () |
|
bool | Contains (T item) |
|
void | CopyTo (T[] array, int arrayIndex) |
|
bool | Remove (T item) |
|
bool | Remove (ref T item) |
|
InternalSet< T >.Enumerator | GetEnumerator () |
|
int | UnionWith (IEnumerable< T > other, bool replaceIfPresent=false) |
|
int | UnionWith (Set< T > other, bool replaceIfPresent=false) |
|
int | UnionWith (MSet< T > other, bool replaceIfPresent=false) |
|
int | ExceptWith (IEnumerable< T > other) |
|
int | ExceptWith (Set< T > other) |
|
int | ExceptWith (MSet< T > other) |
|
int | IntersectWith (IEnumerable< T > other) |
|
int | IntersectWith (Set< T > other) |
| Removes all items from this set that are not present in 'other'. More...
|
|
int | IntersectWith (MSet< T > other) |
| Removes all items from this set that are not present in 'other'. More...
|
|
int | IntersectWith (ISet< T > other) |
| Removes all items from this set that are not present in 'other'. More...
|
|
int | SymmetricExceptWith (IEnumerable< T > other) |
| Modifies the current set to contain only elements that were present either in this set or in the other collection, but not both. More...
|
|
int | SymmetricExceptWith (IEnumerable< T > other, bool xorDuplicates) |
|
int | SymmetricExceptWith (Set< T > other) |
|
int | SymmetricExceptWith (MSet< T > other) |
|
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) |
|
MSet< T > | With (T item) |
|
MSet< T > | Without (T item) |
|
MSet< T > | Union (Set< T > other, bool replaceWithValuesFromOther=false) |
|
MSet< T > | Union (MSet< T > other) |
|
MSet< T > | Union (MSet< T > other, bool replaceWithValuesFromOther) |
|
MSet< T > | Union (IEnumerable< T > other, bool replaceWithValuesFromOther=false) |
|
MSet< T > | Intersect (Set< T > other) |
|
MSet< T > | Intersect (MSet< T > other) |
|
MSet< T > | Intersect (IEnumerable< T > other) |
|
MSet< T > | Except (Set< T > other) |
|
MSet< T > | Except (MSet< T > other) |
|
MSet< T > | Except (IEnumerable< T > other) |
|
MSet< T > | Xor (Set< T > other) |
|
MSet< T > | Xor (MSet< T > other) |
|
MSet< T > | Xor (IEnumerable< T > other) |
|
Set< T > | AsImmutable () |
|
int | RemoveWhere (Predicate< T > match) |
| Removes all elements that match the conditions defined by the specified predicate from this collection. More...
|
|
bool | Toggle (T item) |
| Toggle's an object's presence in the set. More...
|
|
void | ThawRoot () |
|
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...
|
|
OutSetT | Union (InSetT other) |
|
OutSetT | Intersect (InSetT other) |
|
OutSetT | Except (InSetT other) |
|
OutSetT | Xor (InSetT other) |
|
|
static MSet< T > | operator& (MSet< T > a, MSet< T > b) |
|
static MSet< T > | operator& (MSet< T > a, Set< T > b) |
|
static MSet< T > | operator| (MSet< T > a, MSet< T > b) |
|
static MSet< T > | operator| (MSet< T > a, Set< T > b) |
|
static MSet< T > | operator- (MSet< T > a, MSet< T > b) |
|
static MSet< T > | operator- (MSet< T > a, Set< T > b) |
|
static MSet< T > | operator^ (MSet< T > a, MSet< T > b) |
|
static MSet< T > | operator^ (MSet< T > a, Set< T > b) |
|
static MSet< T > | operator+ (T item, MSet< T > a) |
|
static MSet< T > | operator+ (MSet< T > a, T item) |
|
static MSet< T > | operator- (MSet< T > a, T item) |
|
static MSet< T > | operator^ (MSet< T > a, T item) |
|
static | operator Set< T > (MSet< T > a) |
|