2025-03-20 14:15:38 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS.Unity.Internal
|
|
|
|
|
{
|
|
|
|
|
internal readonly struct ReadOnlyList<T> : IEnumerable<T>, IReadOnlyList<T>
|
|
|
|
|
{
|
2025-04-19 11:06:17 +08:00
|
|
|
|
private readonly List<T> _list;
|
2025-03-20 14:15:38 +08:00
|
|
|
|
public ReadOnlyList(List<T> list)
|
|
|
|
|
{
|
|
|
|
|
_list = list;
|
|
|
|
|
}
|
|
|
|
|
public int Count
|
|
|
|
|
{
|
|
|
|
|
get { return _list.Count; }
|
|
|
|
|
}
|
|
|
|
|
public T this[int index]
|
|
|
|
|
{
|
|
|
|
|
get { return _list[index]; }
|
|
|
|
|
set { _list[index] = value; }
|
|
|
|
|
}
|
|
|
|
|
public bool Contains(T item)
|
|
|
|
|
{
|
|
|
|
|
return _list.Contains(item);
|
|
|
|
|
}
|
|
|
|
|
public List<T>.Enumerator GetEnumerator()
|
|
|
|
|
{
|
|
|
|
|
return _list.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
IEnumerator<T> IEnumerable<T>.GetEnumerator()
|
|
|
|
|
{
|
|
|
|
|
return _list.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
|
|
|
{
|
|
|
|
|
return _list.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
public static implicit operator ReadOnlyList<T>(List<T> a) { return new ReadOnlyList<T>(a); }
|
|
|
|
|
}
|
|
|
|
|
}
|