Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ListProvider.cs
Go to the documentation of this file.
5
7
8internal abstract class ListProvider<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable where T : class
9{
10 protected abstract T First { get; }
11
12 protected abstract int ElementCount { get; }
13
14 public T this[int index]
15 {
16 get
17 {
18 if (index == 0)
19 {
20 return First;
21 }
22 return GetElement(index);
23 }
24 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
25 set
26 {
28 }
29 }
30
31 public int Count => ElementCount;
32
33 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
34 public bool IsReadOnly => true;
35
36 protected abstract T GetElement(int index);
37
38 public int IndexOf(T item)
39 {
40 if (First == item)
41 {
42 return 0;
43 }
44 int i = 1;
45 for (int elementCount = ElementCount; i < elementCount; i++)
46 {
47 if (GetElement(i) == item)
48 {
49 return i;
50 }
51 }
52 return -1;
53 }
54
55 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
56 public void Insert(int index, T item)
57 {
59 }
60
61 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
62 public void RemoveAt(int index)
63 {
65 }
66
67 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
68 public void Add(T item)
69 {
71 }
72
73 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
74 public void Clear()
75 {
77 }
78
79 public bool Contains(T item)
80 {
81 return IndexOf(item) != -1;
82 }
83
84 public void CopyTo(T[] array, int index)
85 {
87 if (index < 0)
88 {
89 throw Error.ArgumentOutOfRange("index");
90 }
92 if (index + elementCount > array.Length)
93 {
94 throw new ArgumentException();
95 }
96 array[index++] = First;
97 for (int i = 1; i < elementCount; i++)
98 {
99 array[index++] = GetElement(i);
100 }
101 }
102
103 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
104 public bool Remove(T item)
105 {
107 }
108
110 {
111 yield return First;
112 int i = 1;
113 for (int j = ElementCount; i < j; i++)
114 {
115 yield return GetElement(i);
116 }
117 }
118
123}
static void RequiresNotNull(object value, string paramName)
void Insert(int index, T item)
void CopyTo(T[] array, int index)
static Exception ArgumentOutOfRange(string paramName)
Definition Error.cs:818
new IEnumerator< T > GetEnumerator()