// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable enable using System; using System.Collections; using System.Collections.Generic; using osu.Framework.Extensions.ListExtensions; namespace osu.Framework.Lists { /// /// A wrapper that provides a read-only view into a . /// This can be instantiated via the extension method. /// /// The type of elements contained by the list. public readonly struct SlimReadOnlyListWrapper : IList, IList, IReadOnlyList { private readonly List list; public SlimReadOnlyListWrapper(List list) { this.list = list; } public List.Enumerator GetEnumerator() => list.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public void Add(T item) => throw new NotImplementedException(); public int Add(object? value) => throw new NotImplementedException(); void IList.Clear() => throw new NotImplementedException(); public bool Contains(object? value) => ((IList)list).Contains(value); public int IndexOf(object? value) => ((IList)list).IndexOf(value); public void Insert(int index, object? value) => ((IList)list).Insert(index, value); public void Remove(object? value) => throw new NotImplementedException(); void IList.RemoveAt(int index) => throw new NotImplementedException(); public bool IsFixedSize => ((IList)list).IsFixedSize; bool IList.IsReadOnly => true; object? IList.this[int index] { get => ((IList)list)[index]; set => throw new NotImplementedException(); } void ICollection.Clear() => throw new NotImplementedException(); public bool Contains(T item) => list.Contains(item); public void CopyTo(T[] array, int arrayIndex) => list.CopyTo(array, arrayIndex); public bool Remove(T item) => throw new NotImplementedException(); public void CopyTo(Array array, int index) => ((ICollection)list).CopyTo(array, index); int ICollection.Count => list.Count; public bool IsSynchronized => ((ICollection)list).IsSynchronized; public object SyncRoot => ((ICollection)list).SyncRoot; int ICollection.Count => list.Count; bool ICollection.IsReadOnly => true; public int IndexOf(T item) => list.IndexOf(item); public void Insert(int index, T item) => throw new NotImplementedException(); void IList.RemoveAt(int index) => throw new NotImplementedException(); public T this[int index] { get => list[index]; set => throw new NotImplementedException(); } int IReadOnlyCollection.Count => list.Count; } }