Basic universe management, generation and simulation flow

This commit is contained in:
Aslan 2026-01-26 10:19:40 -05:00
parent 4c078dbede
commit 78fceeb95e
29 changed files with 664 additions and 29 deletions

49
scripts/FastUniqueList.cs Normal file
View file

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
public class FastUniqueList<T>
{
private readonly List<T> list = [];
private readonly HashSet<T> set = [];
public int Count => list.Count;
public T this[int index] => list[index];
public bool Contains(T item)
{
return set.Contains(item);
}
public bool Add(T item)
{
if (!set.Add(item))
{
return false;
}
list.Add(item);
return true;
}
public bool Remove(T item)
{
if (!set.Remove(item))
{
return false;
}
int index = list.IndexOf(item);
int last = list.Count - 1;
list[index] = list[last];
list.RemoveAt(last);
return true;
}
public void ForEach(Action<T> action)
{
list.ForEach(action);
}
}