You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: nanoFramework.CoreLibrary/System/Collections/ArrayList.cs
+71-46Lines changed: 71 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,9 @@ namespace System.Collections
18
18
#endif // NANOCLR_REFLECTION
19
19
publicclassArrayList:IList,ICloneable
20
20
{
21
-
privateObject[]_items;
21
+
privateobject[]_items;
22
22
privateint_size;
23
+
privateobject_syncRoot;
23
24
24
25
// Keep in-sync with c_DefaultCapacity in CLR_RT_HeapBlock_ArrayList in NANOCLR_Runtime__HeapBlock.h
25
26
privateconstintDefaultCapacity=4;
@@ -29,7 +30,7 @@ public class ArrayList : IList, ICloneable
29
30
/// </summary>
30
31
publicArrayList()
31
32
{
32
-
_items=newObject[DefaultCapacity];
33
+
_items=newobject[DefaultCapacity];
33
34
}
34
35
35
36
/// <summary>
@@ -56,61 +57,54 @@ public virtual int Capacity
56
57
/// <value>
57
58
/// The number of elements actually contained in the <see cref="ArrayList"/>.
58
59
/// </value>
59
-
publicvirtualintCount
60
-
{
61
-
get{return_size;}
62
-
}
60
+
publicvirtualintCount=>_size;
63
61
64
62
/// <summary>
65
63
/// Gets a value indicating whether the <see cref="ArrayList"/> has a fixed size.
66
64
/// </summary>
67
65
/// <value>
68
66
/// true if the <see cref="ArrayList"/> has a fixed size; otherwise, false. The default is false.
69
67
/// </value>
70
-
publicvirtualboolIsFixedSize
71
-
{
72
-
get{returnfalse;}
73
-
}
68
+
publicvirtualboolIsFixedSize=>false;
74
69
75
70
/// <summary>
76
71
/// Gets a value indicating whether the <see cref="ArrayList"/> is read-only.
77
72
/// </summary>
78
73
/// <value>
79
74
/// true if the <see cref="ArrayList"/> is read-only; otherwise, false. The default is false.
80
75
/// </value>
81
-
publicvirtualboolIsReadOnly
82
-
{
83
-
get{returnfalse;}
84
-
}
76
+
publicvirtualboolIsReadOnly=>false;
85
77
86
78
/// <summary>
87
79
/// Gets a value indicating whether access to the <see cref="ArrayList"/> is synchronized (thread safe).
88
80
/// </summary>
89
81
/// <value>
90
82
/// true if access to the <see cref="ArrayList"/> is synchronized (thread safe); otherwise, false. The default is false.
91
83
/// </value>
92
-
publicvirtualboolIsSynchronized
93
-
{
94
-
get{returnfalse;}
95
-
}
84
+
publicvirtualboolIsSynchronized=>false;
96
85
97
86
/// <summary>
98
87
/// Gets an object that can be used to synchronize access to the <see cref="ArrayList"/>.
99
88
/// </summary>
100
89
/// <value>
101
90
/// An object that can be used to synchronize access to the <see cref="ArrayList"/>.
102
91
/// </value>
103
-
publicvirtualObjectSyncRoot
92
+
publicvirtualobjectSyncRoot
104
93
{
105
-
get{returnthis;}
94
+
get
95
+
{
96
+
_syncRoot??=newobject();
97
+
98
+
return_syncRoot;
99
+
}
106
100
}
107
101
108
102
/// <summary>
109
103
/// Gets or sets the element at the specified index.
110
104
/// </summary>
111
105
/// <param name="index">The zero-based index of the element to get or set.</param>
112
106
/// <returns></returns>
113
-
publicvirtualexternObjectthis[intindex]
107
+
publicvirtualexternobjectthis[intindex]
114
108
{
115
109
[MethodImpl(MethodImplOptions.InternalCall)]
116
110
get;
@@ -123,9 +117,9 @@ public virtual extern Object this[int index]
123
117
/// Adds an object to the end of the <see cref="ArrayList"/>.
124
118
/// </summary>
125
119
/// <param name="value"></param>
126
-
/// <returns>The <see cref="Object"/> to be added to the end of the <see cref="ArrayList"/>. The value can be <see langword="null"/>.</returns>
120
+
/// <returns>The <see cref="object"/> to be added to the end of the <see cref="ArrayList"/>. The value can be <see langword="null"/>.</returns>
127
121
[MethodImpl(MethodImplOptions.InternalCall)]
128
-
publicvirtualexternintAdd(Objectvalue);
122
+
publicvirtualexternintAdd(objectvalue);
129
123
130
124
/// <summary>
131
125
/// Searches the entire sorted <see cref="ArrayList"/> for an element using the specified comparer and returns the zero-based index of the element.
@@ -135,7 +129,7 @@ public virtual extern Object this[int index]
135
129
/// <para>-or-</para>
136
130
/// <para>nullNothingnullptrunit a <see langword="null"/> reference(Nothing in Visual Basic) to use the IComparable implementation of each element.</para></param>
137
131
/// <returns>The zero-based index of value in the sorted <see cref="ArrayList"/>, if value is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Count.</returns>
@@ -150,15 +144,15 @@ public virtual int BinarySearch(Object value, IComparer comparer)
150
144
/// Creates a shallow copy of the <see cref="ArrayList"/>.
151
145
/// </summary>
152
146
/// <returns>A shallow copy of the <see cref="ArrayList"/>.</returns>
153
-
publicvirtualObjectClone()
147
+
publicvirtualobjectClone()
154
148
{
155
149
vararrayList=newArrayList();
156
150
157
151
if(_size>DefaultCapacity)
158
152
{
159
153
// only re-allocate a new array if the size isn't what we need.
160
154
// otherwise, the one allocated in the constructor will be just fine
161
-
arrayList._items=newObject[_size];
155
+
arrayList._items=newobject[_size];
162
156
}
163
157
164
158
arrayList._size=_size;
@@ -170,8 +164,8 @@ public virtual Object Clone()
170
164
/// Determines whether an element is in the <see cref="ArrayList"/>.
171
165
/// </summary>
172
166
/// <param name="value"></param>
173
-
/// <returns>The<see cref="Object"/> to locate in the <see cref="ArrayList"/>.The value can be <see langword="null"/>.</returns>
174
-
publicvirtualboolContains(Objectvalue)
167
+
/// <returns>The<see cref="object"/> to locate in the <see cref="ArrayList"/>.The value can be <see langword="null"/>.</returns>
168
+
publicvirtualboolContains(objectvalue)
175
169
{
176
170
returnArray.IndexOf(_items,value,0,_size)>=0;
177
171
}
@@ -182,17 +176,26 @@ public virtual bool Contains(Object value)
182
176
/// <param name="array">The one-dimensional Array that is the destination of the elements copied from <see cref="ArrayList"/>. The Array must have zero-based indexing.</param>
183
177
publicvirtualvoidCopyTo(Arrayarray)
184
178
{
185
-
CopyTo(array,0);
179
+
CopyTo(
180
+
array,
181
+
0);
186
182
}
187
183
188
184
/// <summary>
189
185
/// Copies the entire <see cref="ArrayList"/> to a compatible one-dimensional Array, starting at the specified index of the target array.
190
186
/// </summary>
191
187
/// <param name="array">The one-dimensional Array that is the destination of the elements copied from <see cref="ArrayList"/>. The Array must have zero-based indexing. </param>
192
188
/// <param name="index">The zero-based index in array at which copying begins. </param>
193
-
publicvirtualvoidCopyTo(Arrayarray,intindex)
189
+
publicvirtualvoidCopyTo(
190
+
Arrayarray,
191
+
intindex)
194
192
{
195
-
Array.Copy(_items,0,array,index,_size);
193
+
Array.Copy(
194
+
_items,
195
+
0,
196
+
array,
197
+
index,
198
+
_size);
196
199
}
197
200
198
201
/// <summary>
@@ -201,17 +204,24 @@ public virtual void CopyTo(Array array, int index)
201
204
/// <returns>An IEnumerator for the entire <see cref="ArrayList"/>.</returns>
202
205
publicvirtualIEnumeratorGetEnumerator()
203
206
{
204
-
returnnewArray.SzArrayEnumerator(_items,0,_size);
207
+
returnnewArray.SzArrayEnumerator(
208
+
_items,
209
+
0,
210
+
_size);
205
211
}
206
212
207
213
/// <summary>
208
214
/// Searches for the specified Object and returns the zero-based index of the first occurrence within the entire <see cref="ArrayList"/>.
209
215
/// </summary>
210
216
/// <param name="value">The Object to locate in the <see cref="ArrayList"/>. The value can be <see langword="null"/> reference (Nothing in Visual Basic). </param>
211
217
/// <returns>The zero-based index of the first occurrence of value within the entire <see cref="ArrayList"/>, if found; otherwise, -1.</returns>
212
-
publicvirtualintIndexOf(Objectvalue)
218
+
publicvirtualintIndexOf(objectvalue)
213
219
{
214
-
returnArray.IndexOf(_items,value,0,_size);
220
+
returnArray.IndexOf(
221
+
_items,
222
+
value,
223
+
0,
224
+
_size);
215
225
}
216
226
217
227
/// <summary>
@@ -220,9 +230,13 @@ public virtual int IndexOf(Object value)
220
230
/// <param name="value">The Object to locate in the <see cref="ArrayList"/>. The value can be <see langword="null"/> reference (Nothing in Visual Basic). </param>
221
231
/// <param name="startIndex">The zero-based starting index of the search. 0 (zero) is valid in an empty list.</param>
222
232
/// <returns>The zero-based index of the first occurrence of value within the range of elements in the <see cref="ArrayList"/> that extends from startIndex to the last element, if found; otherwise, -1.</returns>
@@ -232,26 +246,37 @@ public virtual int IndexOf(Object value, int startIndex)
232
246
/// <param name="startIndex">The zero-based starting index of the search. 0 (zero) is valid in an empty list.</param>
233
247
/// <param name="count">The number of elements in the section to search. </param>
234
248
/// <returns>The zero-based index of the first occurrence of value within the range of elements in the <see cref="ArrayList"/> that starts at startIndex and contains count number of elements, if found; otherwise, -1.</returns>
0 commit comments