using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Novacoin { public class WrappedListException : Exception { public WrappedListException() { } public WrappedListException(string message) : base(message) { } public WrappedListException(string message, Exception inner) : base(message, inner) { } } public class WrappedList { private int Index; private List Elements; public WrappedList(IList List, int Start) { Elements = new List(List); Index = Start; } public WrappedList(IList List) { Elements = new List(List); Index = 0; } public T GetItem() { if (Elements.Count <= Index) { throw new WrappedListException("No elements left."); } return Elements[Index++]; } public T GetCurrentItem() { return Elements[Index]; } public T[] GetItems(int Count) { if (Elements.Count - Index < Count) { throw new WrappedListException("Unable to read requested amount of data."); } T[] result = Elements.Skip(Index).Take(Count).ToArray(); Index += Count; return result; } public T[] GetCurrentItems(int Count) { if (Elements.Count - Index < Count) { throw new WrappedListException("Unable to read requested amount of data."); } T[] result = Elements.Skip(Index).Take(Count).ToArray(); return result; } public IEnumerable GetEnumerableItems(int Count) { if (Elements.Count - Index < Count) { throw new WrappedListException("Unable to read requested amount of data."); } IEnumerable result = Elements.Skip(Index).Take(Count); Index += Count; return result; } } }