using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StgSharp.Collections { /// /// Part of a collection. This contains a direct reference to origin collection, /// so all change to origin collection will be reflected in this object. /// /// public class ReferencedSlicedCollection : ICollection { private ICollection _collection; private int _begin; private int _length; internal ReferencedSlicedCollection() { _collection = Array.Empty(); _begin = 0; _length = 0; } public ReferencedSlicedCollection(ICollection collection, int begin, int length) { ArgumentNullException.ThrowIfNull(collection); ArgumentOutOfRangeException.ThrowIfLessThan(begin, 0); ArgumentOutOfRangeException.ThrowIfLessThan(length, 0); ArgumentOutOfRangeException.ThrowIfLessThan(begin + length, collection.Count); _collection = collection; _begin = begin; _length = length; } public int Count => _length; public bool IsReadOnly => true; void ICollection.Add(T item) { throw new NotSupportedException(); } public void Clear() { throw new NotImplementedException(); } public bool Contains(T item) { throw new NotImplementedException(); } public void CopyTo(T[] array, int arrayIndex) { throw new NotImplementedException(); } public IEnumerator GetEnumerator() { throw new NotImplementedException(); } public bool Remove(T item) { throw new NotImplementedException(); } IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); } } }