feat: fast list now implements IList
This commit is contained in:
@@ -3,14 +3,15 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Engine.Core;
|
||||
|
||||
public class FastList<T> : IReadOnlyList<T>, IEnumerable<T> where T : notnull
|
||||
public class FastList<T> : IList<T>, IReadOnlyList<T>, IEnumerable<T> where T : notnull
|
||||
{
|
||||
private readonly List<T> items = [];
|
||||
private readonly Dictionary<T, int> indexMap = [];
|
||||
|
||||
public int Count => items.Count;
|
||||
|
||||
public T this[int index] => items[index];
|
||||
public bool IsReadOnly { get; set; } = false;
|
||||
public T this[int index] { get => items[index]; set => items[index] = value; }
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
@@ -66,6 +67,9 @@ public class FastList<T> : IReadOnlyList<T>, IEnumerable<T> where T : notnull
|
||||
indexMap[items[i]] = i;
|
||||
}
|
||||
|
||||
public int IndexOf(T item) => items.IndexOf(item);
|
||||
public void CopyTo(T[] array, int arrayIndex) => items.CopyTo(array, arrayIndex);
|
||||
|
||||
public IEnumerator<T> GetEnumerator() => items.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
|
Reference in New Issue
Block a user