Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ListBase.cs
Go to the documentation of this file.
3
4namespace System.Xml.Xsl;
5
6internal abstract class ListBase<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection
7{
8 public abstract int Count { get; }
9
10 public abstract T this[int index] { get; set; }
11
12 public virtual bool IsFixedSize => true;
13
14 public virtual bool IsReadOnly => true;
15
17
18 object ICollection.SyncRoot => this;
19
20 object IList.this[int index]
21 {
22 get
23 {
24 return this[index];
25 }
26 set
27 {
28 if (!IsCompatibleType(value.GetType()))
29 {
31 }
32 this[index] = (T)value;
33 }
34 }
35
36 public virtual bool Contains(T value)
37 {
38 return IndexOf(value) != -1;
39 }
40
41 public virtual int IndexOf(T value)
42 {
43 for (int i = 0; i < Count; i++)
44 {
45 if (value.Equals(this[i]))
46 {
47 return i;
48 }
49 }
50 return -1;
51 }
52
53 public virtual void CopyTo(T[] array, int index)
54 {
55 for (int i = 0; i < Count; i++)
56 {
57 array[index + i] = this[i];
58 }
59 }
60
62 {
63 return new IListEnumerator<T>(this);
64 }
65
66 public virtual void Add(T value)
67 {
69 }
70
71 public virtual void Insert(int index, T value)
72 {
73 throw new NotSupportedException();
74 }
75
76 public virtual bool Remove(T value)
77 {
78 int num = IndexOf(value);
79 if (num >= 0)
80 {
81 RemoveAt(num);
82 return true;
83 }
84 return false;
85 }
86
87 public virtual void RemoveAt(int index)
88 {
89 throw new NotSupportedException();
90 }
91
92 public virtual void Clear()
93 {
94 for (int num = Count - 1; num >= 0; num--)
95 {
96 RemoveAt(num);
97 }
98 }
99
104
106 {
107 return new IListEnumerator<T>(this);
108 }
109
111 {
112 for (int i = 0; i < Count; i++)
113 {
114 array.SetValue(this[i], index);
115 }
116 }
117
118 int IList.Add(object value)
119 {
120 if (!IsCompatibleType(value.GetType()))
121 {
123 }
124 Add((T)value);
125 return Count - 1;
126 }
127
129 {
130 Clear();
131 }
132
133 bool IList.Contains(object value)
134 {
135 if (!IsCompatibleType(value.GetType()))
136 {
137 return false;
138 }
139 return Contains((T)value);
140 }
141
142 int IList.IndexOf(object value)
143 {
144 if (!IsCompatibleType(value.GetType()))
145 {
146 return -1;
147 }
148 return IndexOf((T)value);
149 }
150
151 void IList.Insert(int index, object value)
152 {
153 if (!IsCompatibleType(value.GetType()))
154 {
156 }
157 Insert(index, (T)value);
158 }
159
160 void IList.Remove(object value)
161 {
162 if (IsCompatibleType(value.GetType()))
163 {
164 Remove((T)value);
165 }
166 }
167
168 private static bool IsCompatibleType(object value)
169 {
170 if ((value == null && !typeof(T).IsValueType) || value is T)
171 {
172 return true;
173 }
174 return false;
175 }
176}
static string Arg_IncompatibleParamType
Definition SR.cs:1824
Definition SR.cs:7
virtual bool Remove(T value)
Definition ListBase.cs:76
static bool IsCompatibleType(object value)
Definition ListBase.cs:168
virtual IListEnumerator< T > GetEnumerator()
Definition ListBase.cs:61
virtual int IndexOf(T value)
Definition ListBase.cs:41
virtual void Clear()
Definition ListBase.cs:92
virtual bool IsFixedSize
Definition ListBase.cs:12
virtual bool Contains(T value)
Definition ListBase.cs:36
virtual bool IsReadOnly
Definition ListBase.cs:14
virtual void RemoveAt(int index)
Definition ListBase.cs:87
virtual void Add(T value)
Definition ListBase.cs:66
virtual void CopyTo(T[] array, int index)
Definition ListBase.cs:53
virtual void Insert(int index, T value)
Definition ListBase.cs:71
void CopyTo(T[] array, int arrayIndex)
new IEnumerator< T > GetEnumerator()
void Insert(int index, T item)