Struct CachedSortedSet<TElement>
- Namespace
- Vintagestory.API.Datastructures
- Assembly
- VintagestoryAPI.dll
Collection of unique ordered elements sorted in ascending order.
Thread-safe.
Pros:
- no memory overhead
- fast to compare (O(1))
- fast to compare via set operations
- fast to iterate
- fast to check containment
- cheap to copy and pass around
Cons: - slow to construct
- slow to merge via set operations
public readonly struct CachedSortedSet<TElement> : IEquatable<CachedSortedSet<TElement>> where TElement : IComparable<TElement>
Type Parameters
TElement
- Implements
-
IEquatable<CachedSortedSet<TElement>>
- Inherited Members
- Extension Methods
Properties
Count
public int Count { get; }
Property Value
Empty
public static CachedSortedSet<TElement> Empty { get; }
Property Value
- CachedSortedSet<TElement>
this[int]
public TElement this[int index] { get; }
Parameters
indexint
Property Value
- TElement
Methods
Contains(TElement)
public bool Contains(TElement value)
Parameters
valueTElement
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Equals(CachedSortedSet<TElement>)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(CachedSortedSet<TElement> other)
Parameters
otherCachedSortedSet<TElement>An object to compare with this object.
Returns
Except(CachedSortedSet<TElement>)
public CachedSortedSet<TElement> Except(CachedSortedSet<TElement> array)
Parameters
arrayCachedSortedSet<TElement>
Returns
- CachedSortedSet<TElement>
Get(IEnumerable<TElement>)
Returns new or existing set. Does sorting and removes duplicate values.
Slow. Get once, store and then use multiple times.
public static CachedSortedSet<TElement> Get(IEnumerable<TElement> elements)
Parameters
elementsIEnumerable<TElement>Any collection of elements
Returns
- CachedSortedSet<TElement>
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Intersect(CachedSortedSet<TElement>)
public CachedSortedSet<TElement> Intersect(CachedSortedSet<TElement> array)
Parameters
arrayCachedSortedSet<TElement>
Returns
- CachedSortedSet<TElement>
IsSubsetOf(CachedSortedSet<TElement>)
public bool IsSubsetOf(CachedSortedSet<TElement> array)
Parameters
arrayCachedSortedSet<TElement>
Returns
IsSupersetOf(CachedSortedSet<TElement>)
public bool IsSupersetOf(CachedSortedSet<TElement> array)
Parameters
arrayCachedSortedSet<TElement>
Returns
Overlaps(CachedSortedSet<TElement>)
public bool Overlaps(CachedSortedSet<TElement> array)
Parameters
arrayCachedSortedSet<TElement>
Returns
OverlapsWithEach(IEnumerable<CachedSortedSet<TElement>>)
public bool OverlapsWithEach(IEnumerable<CachedSortedSet<TElement>> arrays)
Parameters
arraysIEnumerable<CachedSortedSet<TElement>>
Returns
SetEquals(CachedSortedSet<TElement>)
public bool SetEquals(CachedSortedSet<TElement> array)
Parameters
arrayCachedSortedSet<TElement>
Returns
SupersetOfAtLeastOne(IEnumerable<CachedSortedSet<TElement>>)
public bool SupersetOfAtLeastOne(IEnumerable<CachedSortedSet<TElement>> arrays)
Parameters
arraysIEnumerable<CachedSortedSet<TElement>>
Returns
SymmetricExcept(CachedSortedSet<TElement>)
public CachedSortedSet<TElement> SymmetricExcept(CachedSortedSet<TElement> array)
Parameters
arrayCachedSortedSet<TElement>
Returns
- CachedSortedSet<TElement>
ToArray()
public ImmutableArray<TElement> ToArray()
Returns
- ImmutableArray<TElement>
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Union(CachedSortedSet<TElement>)
public CachedSortedSet<TElement> Union(CachedSortedSet<TElement> array)
Parameters
arrayCachedSortedSet<TElement>
Returns
- CachedSortedSet<TElement>
Operators
operator ==(CachedSortedSet<TElement>, CachedSortedSet<TElement>)
public static bool operator ==(CachedSortedSet<TElement> first, CachedSortedSet<TElement> second)
Parameters
firstCachedSortedSet<TElement>secondCachedSortedSet<TElement>
Returns
operator !=(CachedSortedSet<TElement>, CachedSortedSet<TElement>)
public static bool operator !=(CachedSortedSet<TElement> first, CachedSortedSet<TElement> second)
Parameters
firstCachedSortedSet<TElement>secondCachedSortedSet<TElement>