79 lines
2.1 KiB
C#
79 lines
2.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace StgSharp.Collections
|
|
{
|
|
/// <summary>
|
|
/// Part of a collection. This contains a direct reference to origin collection,
|
|
/// so all change to origin collection will be reflected in this object.
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
public class ReferencedSlicedCollection<T> : ICollection<T>
|
|
{
|
|
private ICollection<T> _collection;
|
|
private int _begin;
|
|
private int _length;
|
|
|
|
internal ReferencedSlicedCollection()
|
|
{
|
|
_collection = Array.Empty<T>();
|
|
_begin = 0;
|
|
_length = 0;
|
|
}
|
|
|
|
public ReferencedSlicedCollection(ICollection<T> 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<T>.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<T> GetEnumerator()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public bool Remove(T item)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|