mscorlib(4.0.0.0) API with additions
ArrayList.cs
1 using System.Diagnostics;
3 using System.Security;
5 using System.Threading;
6 
8 {
10  [Serializable]
11  [DebuggerTypeProxy(typeof(ArrayListDebugView))]
12  [DebuggerDisplay("Count = {Count}")]
13  [ComVisible(true)]
15  {
16  [Serializable]
17  private class IListWrapper : ArrayList
18  {
19  [Serializable]
20  private sealed class IListWrapperEnumWrapper : IEnumerator, ICloneable
21  {
22  private IEnumerator _en;
23 
24  private int _remaining;
25 
26  private int _initialStartIndex;
27 
28  private int _initialCount;
29 
30  private bool _firstCall;
31 
32  public object Current
33  {
34  get
35  {
36  if (_firstCall)
37  {
38  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumNotStarted"));
39  }
40  if (_remaining < 0)
41  {
42  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumEnded"));
43  }
44  return _en.Current;
45  }
46  }
47 
48  private IListWrapperEnumWrapper()
49  {
50  }
51 
52  internal IListWrapperEnumWrapper(IListWrapper listWrapper, int startIndex, int count)
53  {
54  _en = listWrapper.GetEnumerator();
55  _initialStartIndex = startIndex;
56  _initialCount = count;
57  while (startIndex-- > 0 && _en.MoveNext())
58  {
59  }
60  _remaining = count;
61  _firstCall = true;
62  }
63 
64  public object Clone()
65  {
66  IListWrapperEnumWrapper listWrapperEnumWrapper = new IListWrapperEnumWrapper();
67  listWrapperEnumWrapper._en = (IEnumerator)((ICloneable)_en).Clone();
68  listWrapperEnumWrapper._initialStartIndex = _initialStartIndex;
69  listWrapperEnumWrapper._initialCount = _initialCount;
70  listWrapperEnumWrapper._remaining = _remaining;
71  listWrapperEnumWrapper._firstCall = _firstCall;
72  return listWrapperEnumWrapper;
73  }
74 
75  public bool MoveNext()
76  {
77  if (_firstCall)
78  {
79  _firstCall = false;
80  if (_remaining-- > 0)
81  {
82  return _en.MoveNext();
83  }
84  return false;
85  }
86  if (_remaining < 0)
87  {
88  return false;
89  }
90  if (_en.MoveNext())
91  {
92  return _remaining-- > 0;
93  }
94  return false;
95  }
96 
97  public void Reset()
98  {
99  _en.Reset();
100  int num = _initialStartIndex;
101  while (num-- > 0 && _en.MoveNext())
102  {
103  }
104  _remaining = _initialCount;
105  _firstCall = true;
106  }
107  }
108 
109  private IList _list;
110 
111  public override int Capacity
112  {
113  get
114  {
115  return _list.Count;
116  }
117  set
118  {
119  if (value < Count)
120  {
121  throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
122  }
123  }
124  }
125 
126  public override int Count => _list.Count;
127 
128  public override bool IsReadOnly => _list.IsReadOnly;
129 
130  public override bool IsFixedSize => _list.IsFixedSize;
131 
132  public override bool IsSynchronized => _list.IsSynchronized;
133 
134  public override object this[int index]
135  {
136  get
137  {
138  return _list[index];
139  }
140  set
141  {
142  _list[index] = value;
143  _version++;
144  }
145  }
146 
147  public override object SyncRoot => _list.SyncRoot;
148 
149  internal IListWrapper(IList list)
150  {
151  _list = list;
152  _version = 0;
153  }
154 
155  public override int Add(object obj)
156  {
157  int result = _list.Add(obj);
158  _version++;
159  return result;
160  }
161 
162  public override void AddRange(ICollection c)
163  {
164  InsertRange(Count, c);
165  }
166 
167  public override int BinarySearch(int index, int count, object value, IComparer comparer)
168  {
169  if (index < 0 || count < 0)
170  {
171  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
172  }
173  if (Count - index < count)
174  {
175  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
176  }
177  if (comparer == null)
178  {
179  comparer = Comparer.Default;
180  }
181  int num = index;
182  int num2 = index + count - 1;
183  while (num <= num2)
184  {
185  int num3 = (num + num2) / 2;
186  int num4 = comparer.Compare(value, _list[num3]);
187  if (num4 == 0)
188  {
189  return num3;
190  }
191  if (num4 < 0)
192  {
193  num2 = num3 - 1;
194  }
195  else
196  {
197  num = num3 + 1;
198  }
199  }
200  return ~num;
201  }
202 
203  public override void Clear()
204  {
205  if (_list.IsFixedSize)
206  {
207  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
208  }
209  _list.Clear();
210  _version++;
211  }
212 
213  public override object Clone()
214  {
215  return new IListWrapper(_list);
216  }
217 
218  public override bool Contains(object obj)
219  {
220  return _list.Contains(obj);
221  }
222 
223  public override void CopyTo(Array array, int index)
224  {
225  _list.CopyTo(array, index);
226  }
227 
228  public override void CopyTo(int index, Array array, int arrayIndex, int count)
229  {
230  if (array == null)
231  {
232  throw new ArgumentNullException("array");
233  }
234  if (index < 0 || arrayIndex < 0)
235  {
236  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "arrayIndex", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
237  }
238  if (count < 0)
239  {
240  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
241  }
242  if (array.Length - arrayIndex < count)
243  {
244  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
245  }
246  if (array.Rank != 1)
247  {
248  throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
249  }
250  if (_list.Count - index < count)
251  {
252  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
253  }
254  for (int i = index; i < index + count; i++)
255  {
256  array.SetValue(_list[i], arrayIndex++);
257  }
258  }
259 
260  public override IEnumerator GetEnumerator()
261  {
262  return _list.GetEnumerator();
263  }
264 
265  public override IEnumerator GetEnumerator(int index, int count)
266  {
267  if (index < 0 || count < 0)
268  {
269  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
270  }
271  if (_list.Count - index < count)
272  {
273  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
274  }
275  return new IListWrapperEnumWrapper(this, index, count);
276  }
277 
278  public override int IndexOf(object value)
279  {
280  return _list.IndexOf(value);
281  }
282 
283  public override int IndexOf(object value, int startIndex)
284  {
285  return IndexOf(value, startIndex, _list.Count - startIndex);
286  }
287 
288  public override int IndexOf(object value, int startIndex, int count)
289  {
290  if (startIndex < 0 || startIndex > Count)
291  {
292  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
293  }
294  if (count < 0 || startIndex > Count - count)
295  {
296  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Count"));
297  }
298  int num = startIndex + count;
299  if (value == null)
300  {
301  for (int i = startIndex; i < num; i++)
302  {
303  if (_list[i] == null)
304  {
305  return i;
306  }
307  }
308  return -1;
309  }
310  for (int j = startIndex; j < num; j++)
311  {
312  if (_list[j] != null && _list[j].Equals(value))
313  {
314  return j;
315  }
316  }
317  return -1;
318  }
319 
320  public override void Insert(int index, object obj)
321  {
322  _list.Insert(index, obj);
323  _version++;
324  }
325 
326  public override void InsertRange(int index, ICollection c)
327  {
328  if (c == null)
329  {
330  throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
331  }
332  if (index < 0 || index > Count)
333  {
334  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
335  }
336  if (c.Count <= 0)
337  {
338  return;
339  }
340  ArrayList arrayList = _list as ArrayList;
341  if (arrayList != null)
342  {
343  arrayList.InsertRange(index, c);
344  }
345  else
346  {
347  IEnumerator enumerator = c.GetEnumerator();
348  while (enumerator.MoveNext())
349  {
350  _list.Insert(index++, enumerator.Current);
351  }
352  }
353  _version++;
354  }
355 
356  public override int LastIndexOf(object value)
357  {
358  return LastIndexOf(value, _list.Count - 1, _list.Count);
359  }
360 
361  public override int LastIndexOf(object value, int startIndex)
362  {
363  return LastIndexOf(value, startIndex, startIndex + 1);
364  }
365 
366  public override int LastIndexOf(object value, int startIndex, int count)
367  {
368  if (_list.Count == 0)
369  {
370  return -1;
371  }
372  if (startIndex < 0 || startIndex >= _list.Count)
373  {
374  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
375  }
376  if (count < 0 || count > startIndex + 1)
377  {
378  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Count"));
379  }
380  int num = startIndex - count + 1;
381  if (value == null)
382  {
383  for (int num2 = startIndex; num2 >= num; num2--)
384  {
385  if (_list[num2] == null)
386  {
387  return num2;
388  }
389  }
390  return -1;
391  }
392  for (int num3 = startIndex; num3 >= num; num3--)
393  {
394  if (_list[num3] != null && _list[num3].Equals(value))
395  {
396  return num3;
397  }
398  }
399  return -1;
400  }
401 
402  public override void Remove(object value)
403  {
404  int num = IndexOf(value);
405  if (num >= 0)
406  {
407  RemoveAt(num);
408  }
409  }
410 
411  public override void RemoveAt(int index)
412  {
413  _list.RemoveAt(index);
414  _version++;
415  }
416 
417  public override void RemoveRange(int index, int count)
418  {
419  if (index < 0 || count < 0)
420  {
421  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
422  }
423  if (_list.Count - index < count)
424  {
425  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
426  }
427  if (count > 0)
428  {
429  _version++;
430  }
431  while (count > 0)
432  {
433  _list.RemoveAt(index);
434  count--;
435  }
436  }
437 
438  public override void Reverse(int index, int count)
439  {
440  if (index < 0 || count < 0)
441  {
442  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
443  }
444  if (_list.Count - index < count)
445  {
446  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
447  }
448  int num = index;
449  int num2 = index + count - 1;
450  while (num < num2)
451  {
452  object value = _list[num];
453  _list[num++] = _list[num2];
454  _list[num2--] = value;
455  }
456  _version++;
457  }
458 
459  public override void SetRange(int index, ICollection c)
460  {
461  if (c == null)
462  {
463  throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
464  }
465  if (index < 0 || index > _list.Count - c.Count)
466  {
467  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
468  }
469  if (c.Count > 0)
470  {
471  IEnumerator enumerator = c.GetEnumerator();
472  while (enumerator.MoveNext())
473  {
474  _list[index++] = enumerator.Current;
475  }
476  _version++;
477  }
478  }
479 
480  public override ArrayList GetRange(int index, int count)
481  {
482  if (index < 0 || count < 0)
483  {
484  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
485  }
486  if (_list.Count - index < count)
487  {
488  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
489  }
490  return new Range(this, index, count);
491  }
492 
493  public override void Sort(int index, int count, IComparer comparer)
494  {
495  if (index < 0 || count < 0)
496  {
497  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
498  }
499  if (_list.Count - index < count)
500  {
501  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
502  }
503  object[] array = new object[count];
504  CopyTo(index, array, 0, count);
505  Array.Sort(array, 0, count, comparer);
506  for (int i = 0; i < count; i++)
507  {
508  _list[i + index] = array[i];
509  }
510  _version++;
511  }
512 
513  public override object[] ToArray()
514  {
515  object[] array = new object[Count];
516  _list.CopyTo(array, 0);
517  return array;
518  }
519 
520  [SecuritySafeCritical]
521  public override Array ToArray(Type type)
522  {
523  if (type == null)
524  {
525  throw new ArgumentNullException("type");
526  }
527  Array array = Array.UnsafeCreateInstance(type, _list.Count);
528  _list.CopyTo(array, 0);
529  return array;
530  }
531 
532  public override void TrimToSize()
533  {
534  }
535  }
536 
537  [Serializable]
538  private class SyncArrayList : ArrayList
539  {
540  private ArrayList _list;
541 
542  private object _root;
543 
544  public override int Capacity
545  {
546  get
547  {
548  lock (_root)
549  {
550  return _list.Capacity;
551  }
552  }
553  set
554  {
555  lock (_root)
556  {
557  _list.Capacity = value;
558  }
559  }
560  }
561 
562  public override int Count
563  {
564  get
565  {
566  lock (_root)
567  {
568  return _list.Count;
569  }
570  }
571  }
572 
573  public override bool IsReadOnly => _list.IsReadOnly;
574 
575  public override bool IsFixedSize => _list.IsFixedSize;
576 
577  public override bool IsSynchronized => true;
578 
579  public override object this[int index]
580  {
581  get
582  {
583  lock (_root)
584  {
585  return _list[index];
586  }
587  }
588  set
589  {
590  lock (_root)
591  {
592  _list[index] = value;
593  }
594  }
595  }
596 
597  public override object SyncRoot => _root;
598 
599  internal SyncArrayList(ArrayList list)
600  : base(trash: false)
601  {
602  _list = list;
603  _root = list.SyncRoot;
604  }
605 
606  public override int Add(object value)
607  {
608  lock (_root)
609  {
610  return _list.Add(value);
611  }
612  }
613 
614  public override void AddRange(ICollection c)
615  {
616  lock (_root)
617  {
618  _list.AddRange(c);
619  }
620  }
621 
622  public override int BinarySearch(object value)
623  {
624  lock (_root)
625  {
626  return _list.BinarySearch(value);
627  }
628  }
629 
630  public override int BinarySearch(object value, IComparer comparer)
631  {
632  lock (_root)
633  {
634  return _list.BinarySearch(value, comparer);
635  }
636  }
637 
638  public override int BinarySearch(int index, int count, object value, IComparer comparer)
639  {
640  lock (_root)
641  {
642  return _list.BinarySearch(index, count, value, comparer);
643  }
644  }
645 
646  public override void Clear()
647  {
648  lock (_root)
649  {
650  _list.Clear();
651  }
652  }
653 
654  public override object Clone()
655  {
656  lock (_root)
657  {
658  return new SyncArrayList((ArrayList)_list.Clone());
659  }
660  }
661 
662  public override bool Contains(object item)
663  {
664  lock (_root)
665  {
666  return _list.Contains(item);
667  }
668  }
669 
670  public override void CopyTo(Array array)
671  {
672  lock (_root)
673  {
674  _list.CopyTo(array);
675  }
676  }
677 
678  public override void CopyTo(Array array, int index)
679  {
680  lock (_root)
681  {
682  _list.CopyTo(array, index);
683  }
684  }
685 
686  public override void CopyTo(int index, Array array, int arrayIndex, int count)
687  {
688  lock (_root)
689  {
690  _list.CopyTo(index, array, arrayIndex, count);
691  }
692  }
693 
694  public override IEnumerator GetEnumerator()
695  {
696  lock (_root)
697  {
698  return _list.GetEnumerator();
699  }
700  }
701 
702  public override IEnumerator GetEnumerator(int index, int count)
703  {
704  lock (_root)
705  {
706  return _list.GetEnumerator(index, count);
707  }
708  }
709 
710  public override int IndexOf(object value)
711  {
712  lock (_root)
713  {
714  return _list.IndexOf(value);
715  }
716  }
717 
718  public override int IndexOf(object value, int startIndex)
719  {
720  lock (_root)
721  {
722  return _list.IndexOf(value, startIndex);
723  }
724  }
725 
726  public override int IndexOf(object value, int startIndex, int count)
727  {
728  lock (_root)
729  {
730  return _list.IndexOf(value, startIndex, count);
731  }
732  }
733 
734  public override void Insert(int index, object value)
735  {
736  lock (_root)
737  {
738  _list.Insert(index, value);
739  }
740  }
741 
742  public override void InsertRange(int index, ICollection c)
743  {
744  lock (_root)
745  {
746  _list.InsertRange(index, c);
747  }
748  }
749 
750  public override int LastIndexOf(object value)
751  {
752  lock (_root)
753  {
754  return _list.LastIndexOf(value);
755  }
756  }
757 
758  public override int LastIndexOf(object value, int startIndex)
759  {
760  lock (_root)
761  {
762  return _list.LastIndexOf(value, startIndex);
763  }
764  }
765 
766  public override int LastIndexOf(object value, int startIndex, int count)
767  {
768  lock (_root)
769  {
770  return _list.LastIndexOf(value, startIndex, count);
771  }
772  }
773 
774  public override void Remove(object value)
775  {
776  lock (_root)
777  {
778  _list.Remove(value);
779  }
780  }
781 
782  public override void RemoveAt(int index)
783  {
784  lock (_root)
785  {
786  _list.RemoveAt(index);
787  }
788  }
789 
790  public override void RemoveRange(int index, int count)
791  {
792  lock (_root)
793  {
794  _list.RemoveRange(index, count);
795  }
796  }
797 
798  public override void Reverse(int index, int count)
799  {
800  lock (_root)
801  {
802  _list.Reverse(index, count);
803  }
804  }
805 
806  public override void SetRange(int index, ICollection c)
807  {
808  lock (_root)
809  {
810  _list.SetRange(index, c);
811  }
812  }
813 
814  public override ArrayList GetRange(int index, int count)
815  {
816  lock (_root)
817  {
818  return _list.GetRange(index, count);
819  }
820  }
821 
822  public override void Sort()
823  {
824  lock (_root)
825  {
826  _list.Sort();
827  }
828  }
829 
830  public override void Sort(IComparer comparer)
831  {
832  lock (_root)
833  {
834  _list.Sort(comparer);
835  }
836  }
837 
838  public override void Sort(int index, int count, IComparer comparer)
839  {
840  lock (_root)
841  {
842  _list.Sort(index, count, comparer);
843  }
844  }
845 
846  public override object[] ToArray()
847  {
848  lock (_root)
849  {
850  return _list.ToArray();
851  }
852  }
853 
854  public override Array ToArray(Type type)
855  {
856  lock (_root)
857  {
858  return _list.ToArray(type);
859  }
860  }
861 
862  public override void TrimToSize()
863  {
864  lock (_root)
865  {
866  _list.TrimToSize();
867  }
868  }
869  }
870 
871  [Serializable]
872  private class SyncIList : IList, ICollection, IEnumerable
873  {
874  private IList _list;
875 
876  private object _root;
877 
878  public virtual int Count
879  {
880  get
881  {
882  lock (_root)
883  {
884  return _list.Count;
885  }
886  }
887  }
888 
889  public virtual bool IsReadOnly => _list.IsReadOnly;
890 
891  public virtual bool IsFixedSize => _list.IsFixedSize;
892 
893  public virtual bool IsSynchronized => true;
894 
895  public virtual object this[int index]
896  {
897  get
898  {
899  lock (_root)
900  {
901  return _list[index];
902  }
903  }
904  set
905  {
906  lock (_root)
907  {
908  _list[index] = value;
909  }
910  }
911  }
912 
913  public virtual object SyncRoot => _root;
914 
915  internal SyncIList(IList list)
916  {
917  _list = list;
918  _root = list.SyncRoot;
919  }
920 
921  public virtual int Add(object value)
922  {
923  lock (_root)
924  {
925  return _list.Add(value);
926  }
927  }
928 
929  public virtual void Clear()
930  {
931  lock (_root)
932  {
933  _list.Clear();
934  }
935  }
936 
937  public virtual bool Contains(object item)
938  {
939  lock (_root)
940  {
941  return _list.Contains(item);
942  }
943  }
944 
945  public virtual void CopyTo(Array array, int index)
946  {
947  lock (_root)
948  {
949  _list.CopyTo(array, index);
950  }
951  }
952 
953  public virtual IEnumerator GetEnumerator()
954  {
955  lock (_root)
956  {
957  return _list.GetEnumerator();
958  }
959  }
960 
961  public virtual int IndexOf(object value)
962  {
963  lock (_root)
964  {
965  return _list.IndexOf(value);
966  }
967  }
968 
969  public virtual void Insert(int index, object value)
970  {
971  lock (_root)
972  {
973  _list.Insert(index, value);
974  }
975  }
976 
977  public virtual void Remove(object value)
978  {
979  lock (_root)
980  {
981  _list.Remove(value);
982  }
983  }
984 
985  public virtual void RemoveAt(int index)
986  {
987  lock (_root)
988  {
989  _list.RemoveAt(index);
990  }
991  }
992  }
993 
994  [Serializable]
995  private class FixedSizeList : IList, ICollection, IEnumerable
996  {
997  private IList _list;
998 
999  public virtual int Count => _list.Count;
1000 
1001  public virtual bool IsReadOnly => _list.IsReadOnly;
1002 
1003  public virtual bool IsFixedSize => true;
1004 
1005  public virtual bool IsSynchronized => _list.IsSynchronized;
1006 
1007  public virtual object this[int index]
1008  {
1009  get
1010  {
1011  return _list[index];
1012  }
1013  set
1014  {
1015  _list[index] = value;
1016  }
1017  }
1018 
1019  public virtual object SyncRoot => _list.SyncRoot;
1020 
1021  internal FixedSizeList(IList l)
1022  {
1023  _list = l;
1024  }
1025 
1026  public virtual int Add(object obj)
1027  {
1028  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1029  }
1030 
1031  public virtual void Clear()
1032  {
1033  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1034  }
1035 
1036  public virtual bool Contains(object obj)
1037  {
1038  return _list.Contains(obj);
1039  }
1040 
1041  public virtual void CopyTo(Array array, int index)
1042  {
1043  _list.CopyTo(array, index);
1044  }
1045 
1046  public virtual IEnumerator GetEnumerator()
1047  {
1048  return _list.GetEnumerator();
1049  }
1050 
1051  public virtual int IndexOf(object value)
1052  {
1053  return _list.IndexOf(value);
1054  }
1055 
1056  public virtual void Insert(int index, object obj)
1057  {
1058  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1059  }
1060 
1061  public virtual void Remove(object value)
1062  {
1063  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1064  }
1065 
1066  public virtual void RemoveAt(int index)
1067  {
1068  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1069  }
1070  }
1071 
1072  [Serializable]
1073  private class FixedSizeArrayList : ArrayList
1074  {
1075  private ArrayList _list;
1076 
1077  public override int Count => _list.Count;
1078 
1079  public override bool IsReadOnly => _list.IsReadOnly;
1080 
1081  public override bool IsFixedSize => true;
1082 
1083  public override bool IsSynchronized => _list.IsSynchronized;
1084 
1085  public override object this[int index]
1086  {
1087  get
1088  {
1089  return _list[index];
1090  }
1091  set
1092  {
1093  _list[index] = value;
1094  _version = _list._version;
1095  }
1096  }
1097 
1098  public override object SyncRoot => _list.SyncRoot;
1099 
1100  public override int Capacity
1101  {
1102  get
1103  {
1104  return _list.Capacity;
1105  }
1106  set
1107  {
1108  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1109  }
1110  }
1111 
1112  internal FixedSizeArrayList(ArrayList l)
1113  {
1114  _list = l;
1115  _version = _list._version;
1116  }
1117 
1118  public override int Add(object obj)
1119  {
1120  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1121  }
1122 
1123  public override void AddRange(ICollection c)
1124  {
1125  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1126  }
1127 
1128  public override int BinarySearch(int index, int count, object value, IComparer comparer)
1129  {
1130  return _list.BinarySearch(index, count, value, comparer);
1131  }
1132 
1133  public override void Clear()
1134  {
1135  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1136  }
1137 
1138  public override object Clone()
1139  {
1140  FixedSizeArrayList fixedSizeArrayList = new FixedSizeArrayList(_list);
1141  fixedSizeArrayList._list = (ArrayList)_list.Clone();
1142  return fixedSizeArrayList;
1143  }
1144 
1145  public override bool Contains(object obj)
1146  {
1147  return _list.Contains(obj);
1148  }
1149 
1150  public override void CopyTo(Array array, int index)
1151  {
1152  _list.CopyTo(array, index);
1153  }
1154 
1155  public override void CopyTo(int index, Array array, int arrayIndex, int count)
1156  {
1157  _list.CopyTo(index, array, arrayIndex, count);
1158  }
1159 
1160  public override IEnumerator GetEnumerator()
1161  {
1162  return _list.GetEnumerator();
1163  }
1164 
1165  public override IEnumerator GetEnumerator(int index, int count)
1166  {
1167  return _list.GetEnumerator(index, count);
1168  }
1169 
1170  public override int IndexOf(object value)
1171  {
1172  return _list.IndexOf(value);
1173  }
1174 
1175  public override int IndexOf(object value, int startIndex)
1176  {
1177  return _list.IndexOf(value, startIndex);
1178  }
1179 
1180  public override int IndexOf(object value, int startIndex, int count)
1181  {
1182  return _list.IndexOf(value, startIndex, count);
1183  }
1184 
1185  public override void Insert(int index, object obj)
1186  {
1187  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1188  }
1189 
1190  public override void InsertRange(int index, ICollection c)
1191  {
1192  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1193  }
1194 
1195  public override int LastIndexOf(object value)
1196  {
1197  return _list.LastIndexOf(value);
1198  }
1199 
1200  public override int LastIndexOf(object value, int startIndex)
1201  {
1202  return _list.LastIndexOf(value, startIndex);
1203  }
1204 
1205  public override int LastIndexOf(object value, int startIndex, int count)
1206  {
1207  return _list.LastIndexOf(value, startIndex, count);
1208  }
1209 
1210  public override void Remove(object value)
1211  {
1212  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1213  }
1214 
1215  public override void RemoveAt(int index)
1216  {
1217  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1218  }
1219 
1220  public override void RemoveRange(int index, int count)
1221  {
1222  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1223  }
1224 
1225  public override void SetRange(int index, ICollection c)
1226  {
1227  _list.SetRange(index, c);
1228  _version = _list._version;
1229  }
1230 
1231  public override ArrayList GetRange(int index, int count)
1232  {
1233  if (index < 0 || count < 0)
1234  {
1235  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1236  }
1237  if (Count - index < count)
1238  {
1239  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
1240  }
1241  return new Range(this, index, count);
1242  }
1243 
1244  public override void Reverse(int index, int count)
1245  {
1246  _list.Reverse(index, count);
1247  _version = _list._version;
1248  }
1249 
1250  public override void Sort(int index, int count, IComparer comparer)
1251  {
1252  _list.Sort(index, count, comparer);
1253  _version = _list._version;
1254  }
1255 
1256  public override object[] ToArray()
1257  {
1258  return _list.ToArray();
1259  }
1260 
1261  public override Array ToArray(Type type)
1262  {
1263  return _list.ToArray(type);
1264  }
1265 
1266  public override void TrimToSize()
1267  {
1268  throw new NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"));
1269  }
1270  }
1271 
1272  [Serializable]
1273  private class ReadOnlyList : IList, ICollection, IEnumerable
1274  {
1275  private IList _list;
1276 
1277  public virtual int Count => _list.Count;
1278 
1279  public virtual bool IsReadOnly => true;
1280 
1281  public virtual bool IsFixedSize => true;
1282 
1283  public virtual bool IsSynchronized => _list.IsSynchronized;
1284 
1285  public virtual object this[int index]
1286  {
1287  get
1288  {
1289  return _list[index];
1290  }
1291  set
1292  {
1293  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1294  }
1295  }
1296 
1297  public virtual object SyncRoot => _list.SyncRoot;
1298 
1299  internal ReadOnlyList(IList l)
1300  {
1301  _list = l;
1302  }
1303 
1304  public virtual int Add(object obj)
1305  {
1306  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1307  }
1308 
1309  public virtual void Clear()
1310  {
1311  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1312  }
1313 
1314  public virtual bool Contains(object obj)
1315  {
1316  return _list.Contains(obj);
1317  }
1318 
1319  public virtual void CopyTo(Array array, int index)
1320  {
1321  _list.CopyTo(array, index);
1322  }
1323 
1324  public virtual IEnumerator GetEnumerator()
1325  {
1326  return _list.GetEnumerator();
1327  }
1328 
1329  public virtual int IndexOf(object value)
1330  {
1331  return _list.IndexOf(value);
1332  }
1333 
1334  public virtual void Insert(int index, object obj)
1335  {
1336  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1337  }
1338 
1339  public virtual void Remove(object value)
1340  {
1341  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1342  }
1343 
1344  public virtual void RemoveAt(int index)
1345  {
1346  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1347  }
1348  }
1349 
1350  [Serializable]
1351  private class ReadOnlyArrayList : ArrayList
1352  {
1353  private ArrayList _list;
1354 
1355  public override int Count => _list.Count;
1356 
1357  public override bool IsReadOnly => true;
1358 
1359  public override bool IsFixedSize => true;
1360 
1361  public override bool IsSynchronized => _list.IsSynchronized;
1362 
1363  public override object this[int index]
1364  {
1365  get
1366  {
1367  return _list[index];
1368  }
1369  set
1370  {
1371  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1372  }
1373  }
1374 
1375  public override object SyncRoot => _list.SyncRoot;
1376 
1377  public override int Capacity
1378  {
1379  get
1380  {
1381  return _list.Capacity;
1382  }
1383  set
1384  {
1385  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1386  }
1387  }
1388 
1389  internal ReadOnlyArrayList(ArrayList l)
1390  {
1391  _list = l;
1392  }
1393 
1394  public override int Add(object obj)
1395  {
1396  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1397  }
1398 
1399  public override void AddRange(ICollection c)
1400  {
1401  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1402  }
1403 
1404  public override int BinarySearch(int index, int count, object value, IComparer comparer)
1405  {
1406  return _list.BinarySearch(index, count, value, comparer);
1407  }
1408 
1409  public override void Clear()
1410  {
1411  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1412  }
1413 
1414  public override object Clone()
1415  {
1416  ReadOnlyArrayList readOnlyArrayList = new ReadOnlyArrayList(_list);
1417  readOnlyArrayList._list = (ArrayList)_list.Clone();
1418  return readOnlyArrayList;
1419  }
1420 
1421  public override bool Contains(object obj)
1422  {
1423  return _list.Contains(obj);
1424  }
1425 
1426  public override void CopyTo(Array array, int index)
1427  {
1428  _list.CopyTo(array, index);
1429  }
1430 
1431  public override void CopyTo(int index, Array array, int arrayIndex, int count)
1432  {
1433  _list.CopyTo(index, array, arrayIndex, count);
1434  }
1435 
1436  public override IEnumerator GetEnumerator()
1437  {
1438  return _list.GetEnumerator();
1439  }
1440 
1441  public override IEnumerator GetEnumerator(int index, int count)
1442  {
1443  return _list.GetEnumerator(index, count);
1444  }
1445 
1446  public override int IndexOf(object value)
1447  {
1448  return _list.IndexOf(value);
1449  }
1450 
1451  public override int IndexOf(object value, int startIndex)
1452  {
1453  return _list.IndexOf(value, startIndex);
1454  }
1455 
1456  public override int IndexOf(object value, int startIndex, int count)
1457  {
1458  return _list.IndexOf(value, startIndex, count);
1459  }
1460 
1461  public override void Insert(int index, object obj)
1462  {
1463  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1464  }
1465 
1466  public override void InsertRange(int index, ICollection c)
1467  {
1468  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1469  }
1470 
1471  public override int LastIndexOf(object value)
1472  {
1473  return _list.LastIndexOf(value);
1474  }
1475 
1476  public override int LastIndexOf(object value, int startIndex)
1477  {
1478  return _list.LastIndexOf(value, startIndex);
1479  }
1480 
1481  public override int LastIndexOf(object value, int startIndex, int count)
1482  {
1483  return _list.LastIndexOf(value, startIndex, count);
1484  }
1485 
1486  public override void Remove(object value)
1487  {
1488  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1489  }
1490 
1491  public override void RemoveAt(int index)
1492  {
1493  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1494  }
1495 
1496  public override void RemoveRange(int index, int count)
1497  {
1498  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1499  }
1500 
1501  public override void SetRange(int index, ICollection c)
1502  {
1503  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1504  }
1505 
1506  public override ArrayList GetRange(int index, int count)
1507  {
1508  if (index < 0 || count < 0)
1509  {
1510  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1511  }
1512  if (Count - index < count)
1513  {
1514  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
1515  }
1516  return new Range(this, index, count);
1517  }
1518 
1519  public override void Reverse(int index, int count)
1520  {
1521  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1522  }
1523 
1524  public override void Sort(int index, int count, IComparer comparer)
1525  {
1526  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1527  }
1528 
1529  public override object[] ToArray()
1530  {
1531  return _list.ToArray();
1532  }
1533 
1534  public override Array ToArray(Type type)
1535  {
1536  return _list.ToArray(type);
1537  }
1538 
1539  public override void TrimToSize()
1540  {
1541  throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection"));
1542  }
1543  }
1544 
1545  [Serializable]
1546  private sealed class ArrayListEnumerator : IEnumerator, ICloneable
1547  {
1548  private ArrayList list;
1549 
1550  private int index;
1551 
1552  private int endIndex;
1553 
1554  private int version;
1555 
1556  private object currentElement;
1557 
1558  private int startIndex;
1559 
1560  public object Current
1561  {
1562  get
1563  {
1564  if (index < startIndex)
1565  {
1566  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumNotStarted"));
1567  }
1568  if (index > endIndex)
1569  {
1570  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumEnded"));
1571  }
1572  return currentElement;
1573  }
1574  }
1575 
1576  internal ArrayListEnumerator(ArrayList list, int index, int count)
1577  {
1578  this.list = list;
1579  startIndex = index;
1580  this.index = index - 1;
1581  endIndex = this.index + count;
1582  version = list._version;
1583  currentElement = null;
1584  }
1585 
1586  public object Clone()
1587  {
1588  return MemberwiseClone();
1589  }
1590 
1591  public bool MoveNext()
1592  {
1593  if (version != list._version)
1594  {
1595  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion"));
1596  }
1597  if (index < endIndex)
1598  {
1599  currentElement = list[++index];
1600  return true;
1601  }
1602  index = endIndex + 1;
1603  return false;
1604  }
1605 
1606  public void Reset()
1607  {
1608  if (version != list._version)
1609  {
1610  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion"));
1611  }
1612  index = startIndex - 1;
1613  }
1614  }
1615 
1616  [Serializable]
1617  private class Range : ArrayList
1618  {
1619  private ArrayList _baseList;
1620 
1621  private int _baseIndex;
1622 
1623  private int _baseSize;
1624 
1625  private int _baseVersion;
1626 
1627  public override int Capacity
1628  {
1629  get
1630  {
1631  return _baseList.Capacity;
1632  }
1633  set
1634  {
1635  if (value < Count)
1636  {
1637  throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
1638  }
1639  }
1640  }
1641 
1642  public override int Count
1643  {
1644  get
1645  {
1646  InternalUpdateRange();
1647  return _baseSize;
1648  }
1649  }
1650 
1651  public override bool IsReadOnly => _baseList.IsReadOnly;
1652 
1653  public override bool IsFixedSize => _baseList.IsFixedSize;
1654 
1655  public override bool IsSynchronized => _baseList.IsSynchronized;
1656 
1657  public override object SyncRoot => _baseList.SyncRoot;
1658 
1659  public override object this[int index]
1660  {
1661  get
1662  {
1663  InternalUpdateRange();
1664  if (index < 0 || index >= _baseSize)
1665  {
1666  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
1667  }
1668  return _baseList[_baseIndex + index];
1669  }
1670  set
1671  {
1672  InternalUpdateRange();
1673  if (index < 0 || index >= _baseSize)
1674  {
1675  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
1676  }
1677  _baseList[_baseIndex + index] = value;
1678  InternalUpdateVersion();
1679  }
1680  }
1681 
1682  internal Range(ArrayList list, int index, int count)
1683  : base(trash: false)
1684  {
1685  _baseList = list;
1686  _baseIndex = index;
1687  _baseSize = count;
1688  _baseVersion = list._version;
1689  _version = list._version;
1690  }
1691 
1692  private void InternalUpdateRange()
1693  {
1694  if (_baseVersion != _baseList._version)
1695  {
1696  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnderlyingArrayListChanged"));
1697  }
1698  }
1699 
1700  private void InternalUpdateVersion()
1701  {
1702  _baseVersion++;
1703  _version++;
1704  }
1705 
1706  public override int Add(object value)
1707  {
1708  InternalUpdateRange();
1709  _baseList.Insert(_baseIndex + _baseSize, value);
1710  InternalUpdateVersion();
1711  return _baseSize++;
1712  }
1713 
1714  public override void AddRange(ICollection c)
1715  {
1716  if (c == null)
1717  {
1718  throw new ArgumentNullException("c");
1719  }
1720  InternalUpdateRange();
1721  int count = c.Count;
1722  if (count > 0)
1723  {
1724  _baseList.InsertRange(_baseIndex + _baseSize, c);
1725  InternalUpdateVersion();
1726  _baseSize += count;
1727  }
1728  }
1729 
1730  public override int BinarySearch(int index, int count, object value, IComparer comparer)
1731  {
1732  if (index < 0 || count < 0)
1733  {
1734  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1735  }
1736  if (_baseSize - index < count)
1737  {
1738  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
1739  }
1740  InternalUpdateRange();
1741  int num = _baseList.BinarySearch(_baseIndex + index, count, value, comparer);
1742  if (num >= 0)
1743  {
1744  return num - _baseIndex;
1745  }
1746  return num + _baseIndex;
1747  }
1748 
1749  public override void Clear()
1750  {
1751  InternalUpdateRange();
1752  if (_baseSize != 0)
1753  {
1754  _baseList.RemoveRange(_baseIndex, _baseSize);
1755  InternalUpdateVersion();
1756  _baseSize = 0;
1757  }
1758  }
1759 
1760  public override object Clone()
1761  {
1762  InternalUpdateRange();
1763  Range range = new Range(_baseList, _baseIndex, _baseSize);
1764  range._baseList = (ArrayList)_baseList.Clone();
1765  return range;
1766  }
1767 
1768  public override bool Contains(object item)
1769  {
1770  InternalUpdateRange();
1771  if (item == null)
1772  {
1773  for (int i = 0; i < _baseSize; i++)
1774  {
1775  if (_baseList[_baseIndex + i] == null)
1776  {
1777  return true;
1778  }
1779  }
1780  return false;
1781  }
1782  for (int j = 0; j < _baseSize; j++)
1783  {
1784  if (_baseList[_baseIndex + j] != null && _baseList[_baseIndex + j].Equals(item))
1785  {
1786  return true;
1787  }
1788  }
1789  return false;
1790  }
1791 
1792  public override void CopyTo(Array array, int index)
1793  {
1794  if (array == null)
1795  {
1796  throw new ArgumentNullException("array");
1797  }
1798  if (array.Rank != 1)
1799  {
1800  throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
1801  }
1802  if (index < 0)
1803  {
1804  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1805  }
1806  if (array.Length - index < _baseSize)
1807  {
1808  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
1809  }
1810  InternalUpdateRange();
1811  _baseList.CopyTo(_baseIndex, array, index, _baseSize);
1812  }
1813 
1814  public override void CopyTo(int index, Array array, int arrayIndex, int count)
1815  {
1816  if (array == null)
1817  {
1818  throw new ArgumentNullException("array");
1819  }
1820  if (array.Rank != 1)
1821  {
1822  throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
1823  }
1824  if (index < 0 || count < 0)
1825  {
1826  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1827  }
1828  if (array.Length - arrayIndex < count)
1829  {
1830  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
1831  }
1832  if (_baseSize - index < count)
1833  {
1834  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
1835  }
1836  InternalUpdateRange();
1837  _baseList.CopyTo(_baseIndex + index, array, arrayIndex, count);
1838  }
1839 
1840  public override IEnumerator GetEnumerator()
1841  {
1842  return GetEnumerator(0, _baseSize);
1843  }
1844 
1845  public override IEnumerator GetEnumerator(int index, int count)
1846  {
1847  if (index < 0 || count < 0)
1848  {
1849  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1850  }
1851  if (_baseSize - index < count)
1852  {
1853  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
1854  }
1855  InternalUpdateRange();
1856  return _baseList.GetEnumerator(_baseIndex + index, count);
1857  }
1858 
1859  public override ArrayList GetRange(int index, int count)
1860  {
1861  if (index < 0 || count < 0)
1862  {
1863  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1864  }
1865  if (_baseSize - index < count)
1866  {
1867  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
1868  }
1869  InternalUpdateRange();
1870  return new Range(this, index, count);
1871  }
1872 
1873  public override int IndexOf(object value)
1874  {
1875  InternalUpdateRange();
1876  int num = _baseList.IndexOf(value, _baseIndex, _baseSize);
1877  if (num >= 0)
1878  {
1879  return num - _baseIndex;
1880  }
1881  return -1;
1882  }
1883 
1884  public override int IndexOf(object value, int startIndex)
1885  {
1886  if (startIndex < 0)
1887  {
1888  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1889  }
1890  if (startIndex > _baseSize)
1891  {
1892  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
1893  }
1894  InternalUpdateRange();
1895  int num = _baseList.IndexOf(value, _baseIndex + startIndex, _baseSize - startIndex);
1896  if (num >= 0)
1897  {
1898  return num - _baseIndex;
1899  }
1900  return -1;
1901  }
1902 
1903  public override int IndexOf(object value, int startIndex, int count)
1904  {
1905  if (startIndex < 0 || startIndex > _baseSize)
1906  {
1907  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
1908  }
1909  if (count < 0 || startIndex > _baseSize - count)
1910  {
1911  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Count"));
1912  }
1913  InternalUpdateRange();
1914  int num = _baseList.IndexOf(value, _baseIndex + startIndex, count);
1915  if (num >= 0)
1916  {
1917  return num - _baseIndex;
1918  }
1919  return -1;
1920  }
1921 
1922  public override void Insert(int index, object value)
1923  {
1924  if (index < 0 || index > _baseSize)
1925  {
1926  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
1927  }
1928  InternalUpdateRange();
1929  _baseList.Insert(_baseIndex + index, value);
1930  InternalUpdateVersion();
1931  _baseSize++;
1932  }
1933 
1934  public override void InsertRange(int index, ICollection c)
1935  {
1936  if (index < 0 || index > _baseSize)
1937  {
1938  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
1939  }
1940  if (c == null)
1941  {
1942  throw new ArgumentNullException("c");
1943  }
1944  InternalUpdateRange();
1945  int count = c.Count;
1946  if (count > 0)
1947  {
1948  _baseList.InsertRange(_baseIndex + index, c);
1949  _baseSize += count;
1950  InternalUpdateVersion();
1951  }
1952  }
1953 
1954  public override int LastIndexOf(object value)
1955  {
1956  InternalUpdateRange();
1957  int num = _baseList.LastIndexOf(value, _baseIndex + _baseSize - 1, _baseSize);
1958  if (num >= 0)
1959  {
1960  return num - _baseIndex;
1961  }
1962  return -1;
1963  }
1964 
1965  public override int LastIndexOf(object value, int startIndex)
1966  {
1967  return LastIndexOf(value, startIndex, startIndex + 1);
1968  }
1969 
1970  public override int LastIndexOf(object value, int startIndex, int count)
1971  {
1972  InternalUpdateRange();
1973  if (_baseSize == 0)
1974  {
1975  return -1;
1976  }
1977  if (startIndex >= _baseSize)
1978  {
1979  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
1980  }
1981  if (startIndex < 0)
1982  {
1983  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
1984  }
1985  int num = _baseList.LastIndexOf(value, _baseIndex + startIndex, count);
1986  if (num >= 0)
1987  {
1988  return num - _baseIndex;
1989  }
1990  return -1;
1991  }
1992 
1993  public override void RemoveAt(int index)
1994  {
1995  if (index < 0 || index >= _baseSize)
1996  {
1997  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
1998  }
1999  InternalUpdateRange();
2000  _baseList.RemoveAt(_baseIndex + index);
2001  InternalUpdateVersion();
2002  _baseSize--;
2003  }
2004 
2005  public override void RemoveRange(int index, int count)
2006  {
2007  if (index < 0 || count < 0)
2008  {
2009  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2010  }
2011  if (_baseSize - index < count)
2012  {
2013  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
2014  }
2015  InternalUpdateRange();
2016  if (count > 0)
2017  {
2018  _baseList.RemoveRange(_baseIndex + index, count);
2019  InternalUpdateVersion();
2020  _baseSize -= count;
2021  }
2022  }
2023 
2024  public override void Reverse(int index, int count)
2025  {
2026  if (index < 0 || count < 0)
2027  {
2028  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2029  }
2030  if (_baseSize - index < count)
2031  {
2032  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
2033  }
2034  InternalUpdateRange();
2035  _baseList.Reverse(_baseIndex + index, count);
2036  InternalUpdateVersion();
2037  }
2038 
2039  public override void SetRange(int index, ICollection c)
2040  {
2041  InternalUpdateRange();
2042  if (index < 0 || index >= _baseSize)
2043  {
2044  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2045  }
2046  _baseList.SetRange(_baseIndex + index, c);
2047  if (c.Count > 0)
2048  {
2049  InternalUpdateVersion();
2050  }
2051  }
2052 
2053  public override void Sort(int index, int count, IComparer comparer)
2054  {
2055  if (index < 0 || count < 0)
2056  {
2057  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2058  }
2059  if (_baseSize - index < count)
2060  {
2061  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
2062  }
2063  InternalUpdateRange();
2064  _baseList.Sort(_baseIndex + index, count, comparer);
2065  InternalUpdateVersion();
2066  }
2067 
2068  public override object[] ToArray()
2069  {
2070  InternalUpdateRange();
2071  object[] array = new object[_baseSize];
2072  Array.Copy(_baseList._items, _baseIndex, array, 0, _baseSize);
2073  return array;
2074  }
2075 
2076  [SecuritySafeCritical]
2077  public override Array ToArray(Type type)
2078  {
2079  if (type == null)
2080  {
2081  throw new ArgumentNullException("type");
2082  }
2083  InternalUpdateRange();
2084  Array array = Array.UnsafeCreateInstance(type, _baseSize);
2085  _baseList.CopyTo(_baseIndex, array, 0, _baseSize);
2086  return array;
2087  }
2088 
2089  public override void TrimToSize()
2090  {
2091  throw new NotSupportedException(Environment.GetResourceString("NotSupported_RangeCollection"));
2092  }
2093  }
2094 
2095  [Serializable]
2096  private sealed class ArrayListEnumeratorSimple : IEnumerator, ICloneable
2097  {
2098  private ArrayList list;
2099 
2100  private int index;
2101 
2102  private int version;
2103 
2104  private object currentElement;
2105 
2106  [NonSerialized]
2107  private bool isArrayList;
2108 
2109  private static object dummyObject = new object();
2110 
2111  public object Current
2112  {
2113  get
2114  {
2115  object obj = currentElement;
2116  if (dummyObject == obj)
2117  {
2118  if (index == -1)
2119  {
2120  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumNotStarted"));
2121  }
2122  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumEnded"));
2123  }
2124  return obj;
2125  }
2126  }
2127 
2128  internal ArrayListEnumeratorSimple(ArrayList list)
2129  {
2130  this.list = list;
2131  index = -1;
2132  version = list._version;
2133  isArrayList = (list.GetType() == typeof(ArrayList));
2134  currentElement = dummyObject;
2135  }
2136 
2137  public object Clone()
2138  {
2139  return MemberwiseClone();
2140  }
2141 
2142  public bool MoveNext()
2143  {
2144  if (version != list._version)
2145  {
2146  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion"));
2147  }
2148  if (isArrayList)
2149  {
2150  if (index < list._size - 1)
2151  {
2152  currentElement = list._items[++index];
2153  return true;
2154  }
2155  currentElement = dummyObject;
2156  index = list._size;
2157  return false;
2158  }
2159  if (index < list.Count - 1)
2160  {
2161  currentElement = list[++index];
2162  return true;
2163  }
2164  index = list.Count;
2165  currentElement = dummyObject;
2166  return false;
2167  }
2168 
2169  public void Reset()
2170  {
2171  if (version != list._version)
2172  {
2173  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion"));
2174  }
2175  currentElement = dummyObject;
2176  index = -1;
2177  }
2178  }
2179 
2180  internal class ArrayListDebugView
2181  {
2182  private ArrayList arrayList;
2183 
2184  [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
2185  public object[] Items
2186  {
2187  get
2188  {
2189  return arrayList.ToArray();
2190  }
2191  }
2192 
2193  public ArrayListDebugView(ArrayList arrayList)
2194  {
2195  if (arrayList == null)
2196  {
2197  throw new ArgumentNullException("arrayList");
2198  }
2199  this.arrayList = arrayList;
2200  }
2201  }
2202 
2203  private object[] _items;
2204 
2205  private int _size;
2206 
2207  private int _version;
2208 
2209  [NonSerialized]
2210  private object _syncRoot;
2211 
2212  private const int _defaultCapacity = 4;
2213 
2214  private static readonly object[] emptyArray = EmptyArray<object>.Value;
2215 
2221  public virtual int Capacity
2222  {
2223  get
2224  {
2225  return _items.Length;
2226  }
2227  set
2228  {
2229  if (value < _size)
2230  {
2231  throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity"));
2232  }
2233  if (value == _items.Length)
2234  {
2235  return;
2236  }
2237  if (value > 0)
2238  {
2239  object[] array = new object[value];
2240  if (_size > 0)
2241  {
2242  Array.Copy(_items, 0, array, 0, _size);
2243  }
2244  _items = array;
2245  }
2246  else
2247  {
2248  _items = new object[4];
2249  }
2250  }
2251  }
2252 
2255  public virtual int Count => _size;
2256 
2260  public virtual bool IsFixedSize => false;
2261 
2265  public virtual bool IsReadOnly => false;
2266 
2270  public virtual bool IsSynchronized => false;
2271 
2274  public virtual object SyncRoot
2275  {
2276  get
2277  {
2278  if (_syncRoot == null)
2279  {
2280  Interlocked.CompareExchange<object>(ref _syncRoot, new object(), (object)null);
2281  }
2282  return _syncRoot;
2283  }
2284  }
2285 
2292  public virtual object this[int index]
2293  {
2294  get
2295  {
2296  if (index < 0 || index >= _size)
2297  {
2298  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2299  }
2300  return _items[index];
2301  }
2302  set
2303  {
2304  if (index < 0 || index >= _size)
2305  {
2306  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2307  }
2308  _items[index] = value;
2309  _version++;
2310  }
2311  }
2312 
2313  internal ArrayList(bool trash)
2314  {
2315  }
2316 
2318  public ArrayList()
2319  {
2320  _items = emptyArray;
2321  }
2322 
2327  public ArrayList(int capacity)
2328  {
2329  if (capacity < 0)
2330  {
2331  throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum", "capacity"));
2332  }
2333  if (capacity == 0)
2334  {
2335  _items = emptyArray;
2336  }
2337  else
2338  {
2339  _items = new object[capacity];
2340  }
2341  }
2342 
2348  {
2349  if (c == null)
2350  {
2351  throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
2352  }
2353  int count = c.Count;
2354  if (count == 0)
2355  {
2356  _items = emptyArray;
2357  return;
2358  }
2359  _items = new object[count];
2360  AddRange(c);
2361  }
2362 
2368  public static ArrayList Adapter(IList list)
2369  {
2370  if (list == null)
2371  {
2372  throw new ArgumentNullException("list");
2373  }
2374  return new IListWrapper(list);
2375  }
2376 
2381  public virtual int Add(object value)
2382  {
2383  if (_size == _items.Length)
2384  {
2385  EnsureCapacity(_size + 1);
2386  }
2387  _items[_size] = value;
2388  _version++;
2389  return _size++;
2390  }
2391 
2397  public virtual void AddRange(ICollection c)
2398  {
2399  InsertRange(_size, c);
2400  }
2401 
2417  public virtual int BinarySearch(int index, int count, object value, IComparer comparer)
2418  {
2419  if (index < 0)
2420  {
2421  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2422  }
2423  if (count < 0)
2424  {
2425  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2426  }
2427  if (_size - index < count)
2428  {
2429  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
2430  }
2431  return Array.BinarySearch(_items, index, count, value, comparer);
2432  }
2433 
2440  public virtual int BinarySearch(object value)
2441  {
2442  return BinarySearch(0, Count, value, null);
2443  }
2444 
2454  public virtual int BinarySearch(object value, IComparer comparer)
2455  {
2456  return BinarySearch(0, Count, value, comparer);
2457  }
2458 
2461  public virtual void Clear()
2462  {
2463  if (_size > 0)
2464  {
2465  Array.Clear(_items, 0, _size);
2466  _size = 0;
2467  }
2468  _version++;
2469  }
2470 
2473  public virtual object Clone()
2474  {
2475  ArrayList arrayList = new ArrayList(_size);
2476  arrayList._size = _size;
2477  arrayList._version = _version;
2478  Array.Copy(_items, 0, arrayList._items, 0, _size);
2479  return arrayList;
2480  }
2481 
2486  public virtual bool Contains(object item)
2487  {
2488  if (item == null)
2489  {
2490  for (int i = 0; i < _size; i++)
2491  {
2492  if (_items[i] == null)
2493  {
2494  return true;
2495  }
2496  }
2497  return false;
2498  }
2499  for (int j = 0; j < _size; j++)
2500  {
2501  if (_items[j] != null && _items[j].Equals(item))
2502  {
2503  return true;
2504  }
2505  }
2506  return false;
2507  }
2508 
2516  public virtual void CopyTo(Array array)
2517  {
2518  CopyTo(array, 0);
2519  }
2520 
2531  public virtual void CopyTo(Array array, int arrayIndex)
2532  {
2533  if (array != null && array.Rank != 1)
2534  {
2535  throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
2536  }
2537  Array.Copy(_items, 0, array, arrayIndex, _size);
2538  }
2539 
2555  public virtual void CopyTo(int index, Array array, int arrayIndex, int count)
2556  {
2557  if (_size - index < count)
2558  {
2559  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
2560  }
2561  if (array != null && array.Rank != 1)
2562  {
2563  throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
2564  }
2565  Array.Copy(_items, index, array, arrayIndex, count);
2566  }
2567 
2568  private void EnsureCapacity(int min)
2569  {
2570  if (_items.Length < min)
2571  {
2572  int num = (_items.Length == 0) ? 4 : (_items.Length * 2);
2573  if ((uint)num > 2146435071u)
2574  {
2575  num = 2146435071;
2576  }
2577  if (num < min)
2578  {
2579  num = min;
2580  }
2581  Capacity = num;
2582  }
2583  }
2584 
2590  public static IList FixedSize(IList list)
2591  {
2592  if (list == null)
2593  {
2594  throw new ArgumentNullException("list");
2595  }
2596  return new FixedSizeList(list);
2597  }
2598 
2604  public static ArrayList FixedSize(ArrayList list)
2605  {
2606  if (list == null)
2607  {
2608  throw new ArgumentNullException("list");
2609  }
2610  return new FixedSizeArrayList(list);
2611  }
2612 
2615  public virtual IEnumerator GetEnumerator()
2616  {
2617  return new ArrayListEnumeratorSimple(this);
2618  }
2619 
2629  public virtual IEnumerator GetEnumerator(int index, int count)
2630  {
2631  if (index < 0)
2632  {
2633  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2634  }
2635  if (count < 0)
2636  {
2637  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2638  }
2639  if (_size - index < count)
2640  {
2641  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
2642  }
2643  return new ArrayListEnumerator(this, index, count);
2644  }
2645 
2649  public virtual int IndexOf(object value)
2650  {
2651  return Array.IndexOf((Array)_items, value, 0, _size);
2652  }
2653 
2660  public virtual int IndexOf(object value, int startIndex)
2661  {
2662  if (startIndex > _size)
2663  {
2664  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2665  }
2666  return Array.IndexOf((Array)_items, value, startIndex, _size - startIndex);
2667  }
2668 
2678  public virtual int IndexOf(object value, int startIndex, int count)
2679  {
2680  if (startIndex > _size)
2681  {
2682  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2683  }
2684  if (count < 0 || startIndex > _size - count)
2685  {
2686  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_Count"));
2687  }
2688  return Array.IndexOf((Array)_items, value, startIndex, count);
2689  }
2690 
2698  public virtual void Insert(int index, object value)
2699  {
2700  if (index < 0 || index > _size)
2701  {
2702  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_ArrayListInsert"));
2703  }
2704  if (_size == _items.Length)
2705  {
2706  EnsureCapacity(_size + 1);
2707  }
2708  if (index < _size)
2709  {
2710  Array.Copy(_items, index, _items, index + 1, _size - index);
2711  }
2712  _items[index] = value;
2713  _size++;
2714  _version++;
2715  }
2716 
2726  public virtual void InsertRange(int index, ICollection c)
2727  {
2728  if (c == null)
2729  {
2730  throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
2731  }
2732  if (index < 0 || index > _size)
2733  {
2734  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2735  }
2736  int count = c.Count;
2737  if (count > 0)
2738  {
2739  EnsureCapacity(_size + count);
2740  if (index < _size)
2741  {
2742  Array.Copy(_items, index, _items, index + count, _size - index);
2743  }
2744  object[] array = new object[count];
2745  c.CopyTo(array, 0);
2746  array.CopyTo(_items, index);
2747  _size += count;
2748  _version++;
2749  }
2750  }
2751 
2755  public virtual int LastIndexOf(object value)
2756  {
2757  return LastIndexOf(value, _size - 1, _size);
2758  }
2759 
2766  public virtual int LastIndexOf(object value, int startIndex)
2767  {
2768  if (startIndex >= _size)
2769  {
2770  throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2771  }
2772  return LastIndexOf(value, startIndex, startIndex + 1);
2773  }
2774 
2784  public virtual int LastIndexOf(object value, int startIndex, int count)
2785  {
2786  if (Count != 0 && (startIndex < 0 || count < 0))
2787  {
2788  throw new ArgumentOutOfRangeException((startIndex < 0) ? "startIndex" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2789  }
2790  if (_size == 0)
2791  {
2792  return -1;
2793  }
2794  if (startIndex >= _size || count > startIndex + 1)
2795  {
2796  throw new ArgumentOutOfRangeException((startIndex >= _size) ? "startIndex" : "count", Environment.GetResourceString("ArgumentOutOfRange_BiggerThanCollection"));
2797  }
2798  return Array.LastIndexOf((Array)_items, value, startIndex, count);
2799  }
2800 
2806  public static IList ReadOnly(IList list)
2807  {
2808  if (list == null)
2809  {
2810  throw new ArgumentNullException("list");
2811  }
2812  return new ReadOnlyList(list);
2813  }
2814 
2820  public static ArrayList ReadOnly(ArrayList list)
2821  {
2822  if (list == null)
2823  {
2824  throw new ArgumentNullException("list");
2825  }
2826  return new ReadOnlyArrayList(list);
2827  }
2828 
2832  public virtual void Remove(object obj)
2833  {
2834  int num = IndexOf(obj);
2835  if (num >= 0)
2836  {
2837  RemoveAt(num);
2838  }
2839  }
2840 
2847  public virtual void RemoveAt(int index)
2848  {
2849  if (index < 0 || index >= _size)
2850  {
2851  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2852  }
2853  _size--;
2854  if (index < _size)
2855  {
2856  Array.Copy(_items, index + 1, _items, index, _size - index);
2857  }
2858  _items[_size] = null;
2859  _version++;
2860  }
2861 
2871  public virtual void RemoveRange(int index, int count)
2872  {
2873  if (index < 0)
2874  {
2875  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2876  }
2877  if (count < 0)
2878  {
2879  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2880  }
2881  if (_size - index < count)
2882  {
2883  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
2884  }
2885  if (count > 0)
2886  {
2887  int num = _size;
2888  _size -= count;
2889  if (index < _size)
2890  {
2891  Array.Copy(_items, index + count, _items, index, _size - index);
2892  }
2893  while (num > _size)
2894  {
2895  _items[--num] = null;
2896  }
2897  _version++;
2898  }
2899  }
2900 
2907  public static ArrayList Repeat(object value, int count)
2908  {
2909  if (count < 0)
2910  {
2911  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2912  }
2913  ArrayList arrayList = new ArrayList((count > 4) ? count : 4);
2914  for (int i = 0; i < count; i++)
2915  {
2916  arrayList.Add(value);
2917  }
2918  return arrayList;
2919  }
2920 
2923  public virtual void Reverse()
2924  {
2925  Reverse(0, Count);
2926  }
2927 
2937  public virtual void Reverse(int index, int count)
2938  {
2939  if (index < 0)
2940  {
2941  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2942  }
2943  if (count < 0)
2944  {
2945  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2946  }
2947  if (_size - index < count)
2948  {
2949  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
2950  }
2951  Array.Reverse(_items, index, count);
2952  _version++;
2953  }
2954 
2964  public virtual void SetRange(int index, ICollection c)
2965  {
2966  if (c == null)
2967  {
2968  throw new ArgumentNullException("c", Environment.GetResourceString("ArgumentNull_Collection"));
2969  }
2970  int count = c.Count;
2971  if (index < 0 || index > _size - count)
2972  {
2973  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
2974  }
2975  if (count > 0)
2976  {
2977  c.CopyTo(_items, index);
2978  _version++;
2979  }
2980  }
2981 
2991  public virtual ArrayList GetRange(int index, int count)
2992  {
2993  if (index < 0 || count < 0)
2994  {
2995  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
2996  }
2997  if (_size - index < count)
2998  {
2999  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
3000  }
3001  return new Range(this, index, count);
3002  }
3003 
3006  public virtual void Sort()
3007  {
3008  Sort(0, Count, Comparer.Default);
3009  }
3010 
3017  public virtual void Sort(IComparer comparer)
3018  {
3019  Sort(0, Count, comparer);
3020  }
3021 
3033  public virtual void Sort(int index, int count, IComparer comparer)
3034  {
3035  if (index < 0)
3036  {
3037  throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
3038  }
3039  if (count < 0)
3040  {
3041  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
3042  }
3043  if (_size - index < count)
3044  {
3045  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
3046  }
3047  Array.Sort(_items, index, count, comparer);
3048  _version++;
3049  }
3050 
3056  [HostProtection(SecurityAction.LinkDemand, Synchronization = true)]
3057  public static IList Synchronized(IList list)
3058  {
3059  if (list == null)
3060  {
3061  throw new ArgumentNullException("list");
3062  }
3063  return new SyncIList(list);
3064  }
3065 
3071  [HostProtection(SecurityAction.LinkDemand, Synchronization = true)]
3072  public static ArrayList Synchronized(ArrayList list)
3073  {
3074  if (list == null)
3075  {
3076  throw new ArgumentNullException("list");
3077  }
3078  return new SyncArrayList(list);
3079  }
3080 
3083  public virtual object[] ToArray()
3084  {
3085  object[] array = new object[_size];
3086  Array.Copy(_items, 0, array, 0, _size);
3087  return array;
3088  }
3089 
3096  [SecuritySafeCritical]
3097  public virtual Array ToArray(Type type)
3098  {
3099  if (type == null)
3100  {
3101  throw new ArgumentNullException("type");
3102  }
3103  Array array = Array.UnsafeCreateInstance(type, _size);
3104  Array.Copy(_items, 0, array, 0, _size);
3105  return array;
3106  }
3107 
3110  public virtual void TrimToSize()
3111  {
3112  Capacity = _size;
3113  }
3114  }
3115 }
static ArrayList ReadOnly(ArrayList list)
Returns a read-only T:System.Collections.ArrayList wrapper.
Definition: ArrayList.cs:2820
virtual bool IsFixedSize
Gets a value indicating whether the T:System.Collections.ArrayList has a fixed size.
Definition: ArrayList.cs:2260
virtual int IndexOf(object value, int startIndex, int count)
Searches for the specified T:System.Object and returns the zero-based index of the first occurrence w...
Definition: ArrayList.cs:2678
virtual void CopyTo(Array array, int arrayIndex)
Copies the entire T:System.Collections.ArrayList to a compatible one-dimensional T:System....
Definition: ArrayList.cs:2531
object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
Definition: ICollection.cs:23
Compares two objects for equivalence, where string comparisons are case-sensitive.
Definition: Comparer.cs:11
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
ArrayList(int capacity)
Initializes a new instance of the T:System.Collections.ArrayList class that is empty and has the spec...
Definition: ArrayList.cs:2327
bool MoveNext()
Advances the enumerator to the next element of the collection.
virtual int LastIndexOf(object value, int startIndex)
Searches for the specified T:System.Object and returns the zero-based index of the last occurrence wi...
Definition: ArrayList.cs:2766
virtual void Insert(int index, object value)
Inserts an element into the T:System.Collections.ArrayList at the specified index.
Definition: ArrayList.cs:2698
virtual void Sort(int index, int count, IComparer comparer)
Sorts the elements in a range of elements in T:System.Collections.ArrayList using the specified compa...
Definition: ArrayList.cs:3033
virtual void TrimToSize()
Sets the capacity to the actual number of elements in the T:System.Collections.ArrayList.
Definition: ArrayList.cs:3110
static void Clear(Array array, int index, int length)
Sets a range of elements in an array to the default value of each element type.
virtual void RemoveAt(int index)
Removes the element at the specified index of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2847
ArrayList()
Initializes a new instance of the T:System.Collections.ArrayList class that is empty and has the defa...
Definition: ArrayList.cs:2318
Represents a non-generic collection of objects that can be individually accessed by index.
Definition: IList.cs:8
static IList Synchronized(IList list)
Returns an T:System.Collections.IList wrapper that is synchronized (thread safe).
Definition: ArrayList.cs:3057
virtual IEnumerator GetEnumerator(int index, int count)
Returns an enumerator for a range of elements in the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2629
void RemoveAt(int index)
Removes the T:System.Collections.IList item at the specified index.
virtual int IndexOf(object value, int startIndex)
Searches for the specified T:System.Object and returns the zero-based index of the first occurrence w...
Definition: ArrayList.cs:2660
void Insert(int index, object value)
Inserts an item to the T:System.Collections.IList at the specified index.
static void Reverse(Array array)
Reverses the sequence of the elements in the entire one-dimensional T:System.Array.
Definition: Array.cs:3171
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2255
Definition: __Canon.cs:3
The exception that is thrown when the value of an argument is outside the allowable range of values a...
virtual void InsertRange(int index, ICollection c)
Inserts the elements of a collection into the T:System.Collections.ArrayList at the specified index.
Definition: ArrayList.cs:2726
bool IsReadOnly
Gets a value indicating whether the T:System.Collections.IList is read-only.
Definition: IList.cs:30
virtual int LastIndexOf(object value)
Searches for the specified T:System.Object and returns the zero-based index of the last occurrence wi...
Definition: ArrayList.cs:2755
virtual void Reverse(int index, int count)
Reverses the order of the elements in the specified range.
Definition: ArrayList.cs:2937
void Clear()
Removes all items from the T:System.Collections.IList.
int IndexOf(object value)
Determines the index of a specific item in the T:System.Collections.IList.
virtual void Clear()
Removes all elements from the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2461
virtual object Clone()
Creates a shallow copy of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2473
bool IsFixedSize
Gets a value indicating whether the T:System.Collections.IList has a fixed size.
Definition: IList.cs:40
static ArrayList Synchronized(ArrayList list)
Returns an T:System.Collections.ArrayList wrapper that is synchronized (thread safe).
Definition: ArrayList.cs:3072
virtual bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ArrayList is synchronized (thread ...
Definition: ArrayList.cs:2270
int Compare(object x, object y)
Compares two objects and returns a value indicating whether one is less than, equal to,...
SecurityAction
Specifies the security actions that can be performed using declarative security.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
Definition: IEnumerable.cs:9
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
virtual void Sort(IComparer comparer)
Sorts the elements in the entire T:System.Collections.ArrayList using the specified comparer.
Definition: ArrayList.cs:3017
virtual bool IsReadOnly
Gets a value indicating whether the T:System.Collections.ArrayList is read-only.
Definition: ArrayList.cs:2265
static void Sort(Array array)
Sorts the elements in an entire one-dimensional T:System.Array using the T:System....
Definition: Array.cs:3259
virtual bool Contains(object item)
Determines whether an element is in the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2486
virtual void AddRange(ICollection c)
Adds the elements of an T:System.Collections.ICollection to the end of the T:System....
Definition: ArrayList.cs:2397
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
static readonly Comparer Default
Represents an instance of T:System.Collections.Comparer that is associated with the P:System....
Definition: Comparer.cs:16
object Current
Gets the element in the collection at the current position of the enumerator.
Definition: IEnumerator.cs:15
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition: ICloneable.cs:7
Exposes a method that compares two objects.
Definition: IComparer.cs:8
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
Definition: ICollection.cs:33
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
virtual int BinarySearch(int index, int count, object value, IComparer comparer)
Searches a range of elements in the sorted T:System.Collections.ArrayList for an element using the sp...
Definition: ArrayList.cs:2417
int Add(object value)
Adds an item to the T:System.Collections.IList.
virtual void CopyTo(Array array)
Copies the entire T:System.Collections.ArrayList to a compatible one-dimensional T:System....
Definition: ArrayList.cs:2516
virtual object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
Definition: ArrayList.cs:2275
virtual void RemoveRange(int index, int count)
Removes a range of elements from the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2871
static int BinarySearch(Array array, object value)
Searches an entire one-dimensional sorted array for a specific element, using the T:System....
Definition: Array.cs:2060
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2381
static ArrayList Repeat(object value, int count)
Returns an T:System.Collections.ArrayList whose elements are copies of the specified value.
Definition: ArrayList.cs:2907
virtual void Reverse()
Reverses the order of the elements in the entire T:System.Collections.ArrayList.
Definition: ArrayList.cs:2923
static IList FixedSize(IList list)
Returns an T:System.Collections.IList wrapper with a fixed size.
Definition: ArrayList.cs:2590
virtual int LastIndexOf(object value, int startIndex, int count)
Searches for the specified T:System.Object and returns the zero-based index of the last occurrence wi...
Definition: ArrayList.cs:2784
The exception that is thrown when one of the arguments provided to a method is not valid.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Definition: Array.cs:1275
virtual int BinarySearch(object value)
Searches the entire sorted T:System.Collections.ArrayList for an element using the default comparer a...
Definition: ArrayList.cs:2440
virtual void Remove(object obj)
Removes the first occurrence of a specific object from the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2832
virtual int BinarySearch(object value, IComparer comparer)
Searches the entire sorted T:System.Collections.ArrayList for an element using the specified comparer...
Definition: ArrayList.cs:2454
virtual IEnumerator GetEnumerator()
Returns an enumerator for the entire T:System.Collections.ArrayList.
Definition: ArrayList.cs:2615
virtual void SetRange(int index, ICollection c)
Copies the elements of a collection over a range of elements in the T:System.Collections....
Definition: ArrayList.cs:2964
The exception that is thrown when a method call is invalid for the object's current state.
void Remove(object value)
Removes the first occurrence of a specific object from the T:System.Collections.IList.
static int LastIndexOf(Array array, object value)
Searches for the specified object and returns the index of the last occurrence within the entire one-...
Definition: Array.cs:2950
bool Contains(object value)
Determines whether the T:System.Collections.IList contains a specific value.
int Count
Gets the number of elements contained in the T:System.Collections.ICollection.
Definition: ICollection.cs:14
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
virtual void CopyTo(int index, Array array, int arrayIndex, int count)
Copies a range of elements from the T:System.Collections.ArrayList to a compatible one-dimensional T:...
Definition: ArrayList.cs:2555
Defines size, enumerators, and synchronization methods for all nongeneric collections.
Definition: ICollection.cs:8
virtual int IndexOf(object value)
Searches for the specified T:System.Object and returns the zero-based index of the first occurrence w...
Definition: ArrayList.cs:2649
virtual Array ToArray(Type type)
Copies the elements of the T:System.Collections.ArrayList to a new array of the specified element typ...
Definition: ArrayList.cs:3097
virtual int Capacity
Gets or sets the number of elements that the T:System.Collections.ArrayList can contain.
Definition: ArrayList.cs:2222
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
static IList ReadOnly(IList list)
Returns a read-only T:System.Collections.IList wrapper.
Definition: ArrayList.cs:2806
DebuggerBrowsableState
Provides display instructions for the debugger.
virtual ArrayList GetRange(int index, int count)
Returns an T:System.Collections.ArrayList which represents a subset of the elements in the source T:S...
Definition: ArrayList.cs:2991
static ArrayList FixedSize(ArrayList list)
Returns an T:System.Collections.ArrayList wrapper with a fixed size.
Definition: ArrayList.cs:2604
Provides atomic operations for variables that are shared by multiple threads.
Definition: Interlocked.cs:10
static ArrayList Adapter(IList list)
Creates an T:System.Collections.ArrayList wrapper for a specific T:System.Collections....
Definition: ArrayList.cs:2368
Supports a simple iteration over a non-generic collection.
Definition: IEnumerator.cs:9
ArrayList(ICollection c)
Initializes a new instance of the T:System.Collections.ArrayList class that contains elements copied ...
Definition: ArrayList.cs:2347
virtual object [] ToArray()
Copies the elements of the T:System.Collections.ArrayList to a new T:System.Object array.
Definition: ArrayList.cs:3083
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Definition: ArrayList.cs:14
virtual void Sort()
Sorts the elements in the entire T:System.Collections.ArrayList.
Definition: ArrayList.cs:3006