Table of Contents

Class CachedCollection<T>

Namespace
TMPEffects.Tags.Collections
Assembly
TMPEffects.dll

Manages a collection of ITagWrapper that represent a cached tag.
Will keep itself synchronized with the given ObservableTagCollection.

public class CachedCollection<T> : IEnumerable<T>, IEnumerable where T : ITagWrapper

Type Parameters

T

The type of tag wrapper / cached tags.

Inheritance
CachedCollection<T>
Implements
Inherited Members

Remarks

Designed for fast "Get tags that contain index" operations.
Ideally use along with TagCollectionManager<TKey> to get the ObservableTagCollection (see implementations of both TMPAnimator and TMPWriter for examples).

Constructors

CachedCollection(ITagCacher<T>, ObservableTagCollection)

public CachedCollection(ITagCacher<T> cacher, ObservableTagCollection tagCollection)

Parameters

cacher ITagCacher<T>
tagCollection ObservableTagCollection

Properties

Count

Amount of cached tags contained in this collection.

public int Count { get; }

Property Value

int

this[int]

Get the cached tag of type T at the given collection index.

public T this[int index] { get; }

Parameters

index int

The collection index.

Property Value

T

The cached tag of type T at the given collection index.

Exceptions

ArgumentOutOfRangeException

Methods

GetAt(int)

Enumerates all cached tags that start at the given text index.

public IEnumerable<T> GetAt(int textIndex)

Parameters

textIndex int

The text index.

Returns

IEnumerable<T>

All cached tags that start at the given text index.

GetContaining(int)

Enumerates all cached tags that contain the given text index.

public IEnumerable<T> GetContaining(int textIndex)

Parameters

textIndex int

The text index.

Returns

IEnumerable<T>

All cached tags that contain the given text index.

GetContainingReversed_NonAlloc(int)

Enumerates all cached tags that contain the given text index in reversed order, without allocating any memory.

public CachedCollection<T>.StructReversedContainingEnumerable GetContainingReversed_NonAlloc(int textIndex)

Parameters

textIndex int

The text index.

Returns

CachedCollection<T>.StructReversedContainingEnumerable

All cached tags that contain the given text index.

GetContaining_NonAlloc(int)

Enumerates all cached tags that contain the given text index, without allocating any memory.

public CachedCollection<T>.StructContainingEnumerable GetContaining_NonAlloc(int textIndex)

Parameters

textIndex int

The text index.

Returns

CachedCollection<T>.StructContainingEnumerable

All cached tags that contain the given text index.

GetEnumerator()

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

HasAny()

Whether this collection has any cached tags.

public bool HasAny()

Returns

bool

true if there is at least one cached tag; false otherwise.

HasAnyAt(int)

Whether this collection has any cached tags that start at the given text index.

public bool HasAnyAt(int index)

Parameters

index int

Returns

bool

true if there is at least one cached tag that starts at the given text index; false otherwise.

HasAnyContaining(int)

Whether this collection has any cached tags that contain the given text index.

public bool HasAnyContaining(int textIndex)

Parameters

textIndex int

The text index.

Returns

bool

true if there is at least one cached tag that contains the given text index; false otherwise.

MinMaxAt(int)

Get the CachedCollection<T>.MinMax for a text index.

public CachedCollection<T>.MinMax MinMaxAt(int textIndex)

Parameters

textIndex int

The text index.

Returns

CachedCollection<T>.MinMax

The CachedCollection<T>.MinMax for the text index, if one exists; otherwise null.