Iterator
Iterator Library for C# and Unity
Install / Use
/learn @jacksondunstan/IteratorREADME
About
- A no-GC version of C#'s
IEnumerator<T>and LINQ - Inspired by C++'s
<iterator>and<algorithm>headers - Useful for any C# project with additional support for Unity
Getting Started
Unity Projects
Clone or download this repository and copy the JacksonDunstanIterator directory somewhere inside your Unity project's Assets directory.
Non-Unity Projects
Clone or download this repository and add all the .cs files directly under the JacksonDunstanIterator directory to your C# project.
Usage
There are three iterator types:
ArrayIterator<T>for managed arrays (T[])ListIterator<T>forList<T>NativeArrayIterator<T>forNativeArray<T>(automatically compiled out when Unity 2018.1+ isn't available)
They all have the same API. Here's the basics of using ArrayIterator<T>:
// Get an array
int[] array = new [] { 30, 10, 20, 40 };
// Get an iterator to the beginning of the array
ArrayIterator<int> begin = array.Begin();
// Get the value of the iterator
int val = begin.GetCurrent();
// Move to the next element
ArrayIterator<int> second = begin.GetNext();
// Get an iterator to one past the end of the array
ArrayIterator<int> end = array.End();
// Reverse [ 10, 20, 40] so the array is [ 30, 40, 20, 10 ]
second.Reverse(end);
// Search for an element satisfying a condition
ArrayIterator<int> it20 = begin.FindIf(end, e => e < 25);
There is much more functionality available. See the source for more.
To read about the making of this library, see the Enumerables Without the Garbage series:
License
Related Skills
node-connect
340.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.2kCommit, push, and open a PR
