FastEnumerator<T> Struct

Summary

An System.Collections.Generic.IEnumerator`1 for any System.Collections.Generic.IList`1 which doesn't bother checking if the target has been modified. This gives it good performance but also makes it slightly less safe to use.
Assembly
Animancer.dll
Namespace
Animancer
Interfaces
  • IReadOnlyList<T>
  • IEnumerator<T>
Base Types
  • ValueType
graph BT Type-->Base0["ValueType"] Type-.->Interface0["IReadOnlyList<T>"] Type-.->Interface1["IEnumerator<T>"] Type["FastEnumerator<T>"] class Type type-node

Syntax

public struct FastEnumerator<T> : ValueType, IReadOnlyList<T>, IEnumerator<T>

Remarks

This struct also implements System.Collections.Generic.IEnumerable`1 so it can be used in foreach statements and System.Collections.Generic.IList`1 to allow the target collection to be modified without breaking the enumerator (though doing so is still somewhat dangerous so use with care).

Example:
var numbers = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, };
var count = 4;
foreach (var number in new FastEnumerator<int>(numbers, count))
{
    Debug.Log(number);
}

// Log Output:
// 9
// 8
// 7
// 6

Type Parameters

Name Description
T

Constructors

Name Summary
FastEnumerator(IList<T>) Creates a new Animancer.FastEnumerator`1.
FastEnumerator(IList<T>, int) Creates a new Animancer.FastEnumerator`1.

Properties

Name Value Summary
Count int
[System.Collections.Generic.ICollection`1] The number of items in the Animancer.FastEnumerator`1.List (which can be less than the System.Collections.Generic.ICollection`1.Count of the Animancer.FastEnumerator`1.List).
Current T
The item at the current Animancer.FastEnumerator`1.Index in the Animancer.FastEnumerator`1.List.
Index int
The position of the Animancer.FastEnumerator`1.Current item in the Animancer.FastEnumerator`1.List.
this[int] T
[System.Collections.Generic.IList`1] The item at the specified `index` in the Animancer.FastEnumerator`1.List.

Methods

Name Value Summary
Contains(T) bool
[System.Collections.Generic.ICollection`1] Does the Animancer.FastEnumerator`1.List contain the `item`?
CopyTo(T[], int) void
[System.Collections.Generic.ICollection`1] Copies the contents of the Animancer.FastEnumerator`1.List into the `array`.
GetEnumerator() FastEnumerator<T>
Returns this.
IndexOf(T) int
[System.Collections.Generic.IList`1] Returns the first index of the `item` in the Animancer.FastEnumerator`1.List.
MoveNext() bool
Moves to the next item in the Animancer.FastEnumerator`1.List and returns true if there is one.
MovePrevious() bool
Moves to the previous item in the Animancer.FastEnumerator`1.List and returns true if there is one.
Reset() void
[System.Collections.IEnumerator] Reverts this enumerator to the start of the Animancer.FastEnumerator`1.List.