2 using System.Collections.Generic;
5 using System.Threading.Tasks;
9 public class WrappedListException : Exception
11 public WrappedListException()
15 public WrappedListException(string message)
20 public WrappedListException(string message, Exception inner)
21 : base(message, inner)
26 public class WrappedList<T>
29 private List<T> Elements;
33 get { return Elements.Count - Index; }
36 public WrappedList(IList<T> List, int Start)
38 Elements = new List<T>(List);
42 public WrappedList(IList<T> List)
44 Elements = new List<T>(List);
50 if (Elements.Count <= Index)
52 throw new WrappedListException("No elements left.");
55 return Elements[Index++];
58 public T[] GetItems(int Count)
60 if (ItemsLeft < Count)
62 throw new WrappedListException("Unable to read requested amount of data.");
65 T[] result = Elements.Skip<T>(Index).Take<T>(Count).ToArray<T>();
71 public IEnumerable<T> GetEnumerableItems(int Count)
73 if (Elements.Count - Index < Count)
75 throw new WrappedListException("Unable to read requested amount of data.");
78 IEnumerable<T> result = Elements.Skip<T>(Index).Take<T>(Count);