using System; namespace Fusion.Addons.SimpleKCC { internal sealed class KCCFastStack where T : class, new() { private T[] _items; private int _count; public KCCFastStack(int capacity, bool createInstances) { _items = new T[capacity]; _count = 0; if (createInstances) { _count = capacity; for (int i = 0; i < capacity; i++) { _items[i] = new T(); } } } public T PopOrCreate() { if (_count > 0) { _count--; return _items[_count]; } return new T(); } public void Push(T item) { if (_count == _items.Length) { Array.Resize(ref _items, _items.Length * 2); } _items[_count] = item; _count++; } } }