Table of Contents

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
Inherited Members
Extension Methods

Properties

Count

public int Count { get; }

Property Value

int

Empty

public static CachedSortedSet<TElement> Empty { get; }

Property Value

CachedSortedSet<TElement>

this[int]

public TElement this[int index] { get; }

Parameters

index int

Property Value

TElement

Methods

Contains(TElement)

public bool Contains(TElement value)

Parameters

value TElement

Returns

bool

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

other CachedSortedSet<TElement>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Except(CachedSortedSet<TElement>)

public CachedSortedSet<TElement> Except(CachedSortedSet<TElement> array)

Parameters

array CachedSortedSet<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

elements IEnumerable<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

array CachedSortedSet<TElement>

Returns

CachedSortedSet<TElement>

IsSubsetOf(CachedSortedSet<TElement>)

public bool IsSubsetOf(CachedSortedSet<TElement> array)

Parameters

array CachedSortedSet<TElement>

Returns

bool

IsSupersetOf(CachedSortedSet<TElement>)

public bool IsSupersetOf(CachedSortedSet<TElement> array)

Parameters

array CachedSortedSet<TElement>

Returns

bool

Overlaps(CachedSortedSet<TElement>)

public bool Overlaps(CachedSortedSet<TElement> array)

Parameters

array CachedSortedSet<TElement>

Returns

bool

OverlapsWithEach(IEnumerable<CachedSortedSet<TElement>>)

public bool OverlapsWithEach(IEnumerable<CachedSortedSet<TElement>> arrays)

Parameters

arrays IEnumerable<CachedSortedSet<TElement>>

Returns

bool

SetEquals(CachedSortedSet<TElement>)

public bool SetEquals(CachedSortedSet<TElement> array)

Parameters

array CachedSortedSet<TElement>

Returns

bool

SupersetOfAtLeastOne(IEnumerable<CachedSortedSet<TElement>>)

public bool SupersetOfAtLeastOne(IEnumerable<CachedSortedSet<TElement>> arrays)

Parameters

arrays IEnumerable<CachedSortedSet<TElement>>

Returns

bool

SymmetricExcept(CachedSortedSet<TElement>)

public CachedSortedSet<TElement> SymmetricExcept(CachedSortedSet<TElement> array)

Parameters

array CachedSortedSet<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

array CachedSortedSet<TElement>

Returns

CachedSortedSet<TElement>

Operators

operator ==(CachedSortedSet<TElement>, CachedSortedSet<TElement>)

public static bool operator ==(CachedSortedSet<TElement> first, CachedSortedSet<TElement> second)

Parameters

first CachedSortedSet<TElement>
second CachedSortedSet<TElement>

Returns

bool

operator !=(CachedSortedSet<TElement>, CachedSortedSet<TElement>)

public static bool operator !=(CachedSortedSet<TElement> first, CachedSortedSet<TElement> second)

Parameters

first CachedSortedSet<TElement>
second CachedSortedSet<TElement>

Returns

bool