Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ImmutableList.cs
Go to the documentation of this file.
5using System.Linq;
8
10
11public static class ImmutableList
12{
14 {
15 return ImmutableList<T>.Empty;
16 }
17
19 {
20 return ImmutableList<T>.Empty.Add(item);
21 }
22
24 {
25 return ImmutableList<T>.Empty.AddRange(items);
26 }
27
28 public static ImmutableList<T> Create<T>(params T[] items)
29 {
30 return ImmutableList<T>.Empty.AddRange(items);
31 }
32
33 public static ImmutableList<T>.Builder CreateBuilder<T>()
34 {
35 return Create<T>().ToBuilder();
36 }
37
39 {
41 {
42 return result;
43 }
45 }
46
48 {
49 Requires.NotNull(builder, "builder");
50 return builder.ToImmutable();
51 }
52
54 {
55 Requires.NotNull(list, "list");
57 }
58
60 {
61 Requires.NotNull(list, "list");
62 return list.Remove(value, EqualityComparer<T>.Default);
63 }
64
66 {
67 Requires.NotNull(list, "list");
68 return list.RemoveRange(items, EqualityComparer<T>.Default);
69 }
70
71 public static int IndexOf<T>(this IImmutableList<T> list, T item)
72 {
73 Requires.NotNull(list, "list");
74 return list.IndexOf(item, 0, list.Count, EqualityComparer<T>.Default);
75 }
76
78 {
79 Requires.NotNull(list, "list");
80 return list.IndexOf(item, 0, list.Count, equalityComparer);
81 }
82
83 public static int IndexOf<T>(this IImmutableList<T> list, T item, int startIndex)
84 {
85 Requires.NotNull(list, "list");
86 return list.IndexOf(item, startIndex, list.Count - startIndex, EqualityComparer<T>.Default);
87 }
88
89 public static int IndexOf<T>(this IImmutableList<T> list, T item, int startIndex, int count)
90 {
91 Requires.NotNull(list, "list");
93 }
94
95 public static int LastIndexOf<T>(this IImmutableList<T> list, T item)
96 {
97 Requires.NotNull(list, "list");
98 if (list.Count == 0)
99 {
100 return -1;
101 }
102 return list.LastIndexOf(item, list.Count - 1, list.Count, EqualityComparer<T>.Default);
103 }
104
106 {
107 Requires.NotNull(list, "list");
108 if (list.Count == 0)
109 {
110 return -1;
111 }
112 return list.LastIndexOf(item, list.Count - 1, list.Count, equalityComparer);
113 }
114
115 public static int LastIndexOf<T>(this IImmutableList<T> list, T item, int startIndex)
116 {
117 Requires.NotNull(list, "list");
118 if (list.Count == 0 && startIndex == 0)
119 {
120 return -1;
121 }
122 return list.LastIndexOf(item, startIndex, startIndex + 1, EqualityComparer<T>.Default);
123 }
124
125 public static int LastIndexOf<T>(this IImmutableList<T> list, T item, int startIndex, int count)
126 {
127 Requires.NotNull(list, "list");
128 return list.LastIndexOf(item, startIndex, count, EqualityComparer<T>.Default);
129 }
130}
131[DebuggerDisplay("Count = {Count}")]
134{
135 [DebuggerDisplay("Count = {Count}")]
138 {
140
142
143 private int _version;
144
145 private object _syncRoot;
146
147 public int Count => Root.Count;
148
150
151 internal int Version => _version;
152
153 internal Node Root
154 {
155 get
156 {
157 return _root;
158 }
159 private set
160 {
161 _version++;
162 if (_root != value)
163 {
164 _root = value;
165 _immutable = null;
166 }
167 }
168 }
169
170 public T this[int index]
171 {
172 get
173 {
174 return Root.ItemRef(index);
175 }
176 set
177 {
179 }
180 }
181
182 T IOrderedCollection<T>.this[int index] => this[index];
183
184 bool IList.IsFixedSize => false;
185
186 bool IList.IsReadOnly => false;
187
188 object? IList.this[int index]
189 {
190 get
191 {
192 return this[index];
193 }
194 set
195 {
196 this[index] = (T)value;
197 }
198 }
199
201 bool ICollection.IsSynchronized => false;
202
204 object ICollection.SyncRoot
205 {
206 get
207 {
208 if (_syncRoot == null)
209 {
210 Interlocked.CompareExchange<object>(ref _syncRoot, new object(), (object)null);
211 }
212 return _syncRoot;
213 }
214 }
215
217 {
218 Requires.NotNull(list, "list");
219 _root = list._root;
221 }
222
223 public ref readonly T ItemRef(int index)
224 {
225 return ref Root.ItemRef(index);
226 }
227
228 public int IndexOf(T item)
229 {
231 }
232
233 public void Insert(int index, T item)
234 {
236 }
237
238 public void RemoveAt(int index)
239 {
241 }
242
243 public void Add(T item)
244 {
245 Root = Root.Add(item);
246 }
247
248 public void Clear()
249 {
251 }
252
253 public bool Contains(T item)
254 {
255 return IndexOf(item) >= 0;
256 }
257
258 public bool Remove(T item)
259 {
260 int num = IndexOf(item);
261 if (num < 0)
262 {
263 return false;
264 }
265 Root = Root.RemoveAt(num);
266 return true;
267 }
268
270 {
271 return Root.GetEnumerator(this);
272 }
273
278
283
285 {
286 Requires.NotNull(action, "action");
288 while (enumerator.MoveNext())
289 {
290 T current = enumerator.Current;
291 action(current);
292 }
293 }
294
295 public void CopyTo(T[] array)
296 {
298 }
299
300 public void CopyTo(T[] array, int arrayIndex)
301 {
303 }
304
305 public void CopyTo(int index, T[] array, int arrayIndex, int count)
306 {
308 }
309
311 {
312 Requires.Range(index >= 0, "index");
313 Requires.Range(count >= 0, "count");
314 Requires.Range(index + count <= Count, "count");
315 return ImmutableList<T>.WrapNode(Node.NodeTreeFromList(this, index, count));
316 }
317
319 {
320 Requires.NotNull(converter, "converter");
321 return ImmutableList<TOutput>.WrapNode(_root.ConvertAll(converter));
322 }
323
325 {
326 return _root.Exists(match);
327 }
328
330 {
331 return _root.Find(match);
332 }
333
335 {
336 return _root.FindAll(match);
337 }
338
340 {
341 return _root.FindIndex(match);
342 }
343
345 {
347 }
348
350 {
352 }
353
355 {
356 return _root.FindLast(match);
357 }
358
360 {
361 return _root.FindLastIndex(match);
362 }
363
365 {
367 }
368
370 {
372 }
373
374 public int IndexOf(T item, int index)
375 {
377 }
378
379 public int IndexOf(T item, int index, int count)
380 {
382 }
383
388
389 public int LastIndexOf(T item)
390 {
391 if (Count == 0)
392 {
393 return -1;
394 }
396 }
397
398 public int LastIndexOf(T item, int startIndex)
399 {
400 if (Count == 0 && startIndex == 0)
401 {
402 return -1;
403 }
405 }
406
407 public int LastIndexOf(T item, int startIndex, int count)
408 {
410 }
411
416
418 {
419 return _root.TrueForAll(match);
420 }
421
422 public void AddRange(IEnumerable<T> items)
423 {
424 Requires.NotNull(items, "items");
425 Root = Root.AddRange(items);
426 }
427
428 public void InsertRange(int index, IEnumerable<T> items)
429 {
430 Requires.Range(index >= 0 && index <= Count, "index");
431 Requires.NotNull(items, "items");
432 Root = Root.InsertRange(index, items);
433 }
434
436 {
437 Requires.NotNull(match, "match");
438 int count = Count;
440 return count - Count;
441 }
442
443 public void Reverse()
444 {
445 Reverse(0, Count);
446 }
447
448 public void Reverse(int index, int count)
449 {
450 Requires.Range(index >= 0, "index");
451 Requires.Range(count >= 0, "count");
452 Requires.Range(index + count <= Count, "count");
454 }
455
456 public void Sort()
457 {
458 Root = Root.Sort();
459 }
460
462 {
463 Requires.NotNull(comparison, "comparison");
465 }
466
468 {
470 }
471
472 public void Sort(int index, int count, IComparer<T>? comparer)
473 {
474 Requires.Range(index >= 0, "index");
475 Requires.Range(count >= 0, "count");
476 Requires.Range(index + count <= Count, "count");
478 }
479
480 public int BinarySearch(T item)
481 {
482 return BinarySearch(item, null);
483 }
484
486 {
487 return BinarySearch(0, Count, item, comparer);
488 }
489
491 {
493 }
494
496 {
497 if (_immutable == null)
498 {
499 _immutable = ImmutableList<T>.WrapNode(Root);
500 }
501 return _immutable;
502 }
503
504 int IList.Add(object value)
505 {
506 Add((T)value);
507 return Count - 1;
508 }
509
511 {
512 Clear();
513 }
514
515 bool IList.Contains(object value)
516 {
518 {
519 return Contains((T)value);
520 }
521 return false;
522 }
523
524 int IList.IndexOf(object value)
525 {
527 {
528 return IndexOf((T)value);
529 }
530 return -1;
531 }
532
533 void IList.Insert(int index, object value)
534 {
535 Insert(index, (T)value);
536 }
537
538 void IList.Remove(object value)
539 {
541 {
542 Remove((T)value);
543 }
544 }
545
550 }
551
554 {
556
557 private readonly Builder _builder;
558
559 private readonly int _poolUserId;
560
561 private readonly int _startIndex;
562
563 private readonly int _count;
564
565 private int _remainingCount;
566
567 private readonly bool _reversed;
568
569 private Node _root;
570
572
573 private Node _current;
574
576
577 int ISecurePooledObjectUser.PoolUserId => _poolUserId;
578
579 public T Current
580 {
581 get
582 {
584 if (_current != null)
585 {
586 return _current.Value;
587 }
588 throw new InvalidOperationException();
589 }
590 }
591
592 object? IEnumerator.Current => Current;
593
594 internal Enumerator(Node root, Builder? builder = null, int startIndex = -1, int count = -1, bool reversed = false)
595 {
596 Requires.NotNull(root, "root");
597 Requires.Range(startIndex >= -1, "startIndex");
598 Requires.Range(count >= -1, "count");
599 Requires.Argument(reversed || count == -1 || ((startIndex != -1) ? startIndex : 0) + count <= root.Count);
600 Requires.Argument(!reversed || count == -1 || ((startIndex == -1) ? (root.Count - 1) : startIndex) - count + 1 >= 0);
601 _root = root;
603 _current = null;
604 _startIndex = ((startIndex >= 0) ? startIndex : (reversed ? (root.Count - 1) : 0));
605 _count = ((count == -1) ? root.Count : count);
608 _enumeratingBuilderVersion = builder?.Version ?? (-1);
610 _stack = null;
611 if (_count > 0)
612 {
613 if (!s_EnumeratingStacks.TryTake(this, out _stack))
614 {
615 _stack = s_EnumeratingStacks.PrepNew(this, new Stack<RefAsValueType<Node>>(root.Height));
616 }
617 ResetStack();
618 }
619 }
620
621 public void Dispose()
622 {
623 _root = null;
624 _current = null;
625 if (_stack != null && _stack.TryUse(ref this, out var value))
626 {
627 value.ClearFastWhenEmpty();
628 s_EnumeratingStacks.TryAdd(this, _stack);
629 }
630 _stack = null;
631 }
632
633 public bool MoveNext()
634 {
637 if (_stack != null)
638 {
639 Stack<RefAsValueType<Node>> stack = _stack.Use(ref this);
640 if (_remainingCount > 0 && stack.Count > 0)
641 {
642 PushNext(NextBranch(_current = stack.Pop().Value));
644 return true;
645 }
646 }
647 _current = null;
648 return false;
649 }
650
651 public void Reset()
652 {
656 if (_stack != null)
657 {
658 ResetStack();
659 }
660 }
661
662 private void ResetStack()
663 {
664 Stack<RefAsValueType<Node>> stack = _stack.Use(ref this);
665 stack.ClearFastWhenEmpty();
666 Node node = _root;
667 int num = (_reversed ? (_root.Count - _startIndex - 1) : _startIndex);
668 while (!node.IsEmpty && num != PreviousBranch(node).Count)
669 {
670 if (num < PreviousBranch(node).Count)
671 {
672 stack.Push(new RefAsValueType<Node>(node));
674 }
675 else
676 {
677 num -= PreviousBranch(node).Count + 1;
679 }
680 }
681 if (!node.IsEmpty)
682 {
683 stack.Push(new RefAsValueType<Node>(node));
684 }
685 }
686
688 {
689 if (!_reversed)
690 {
691 return node.Right;
692 }
693 return node.Left;
694 }
695
697 {
698 if (!_reversed)
699 {
700 return node.Left;
701 }
702 return node.Right;
703 }
704
705 private void ThrowIfDisposed()
706 {
707 if (_root == null || (_stack != null && !_stack.IsOwned(ref this)))
708 {
709 Requires.FailObjectDisposed(this);
710 }
711 }
712
720
721 private void PushNext(Node node)
722 {
723 Requires.NotNull(node, "node");
724 if (!node.IsEmpty)
725 {
726 Stack<RefAsValueType<Node>> stack = _stack.Use(ref this);
727 while (!node.IsEmpty)
728 {
729 stack.Push(new RefAsValueType<Node>(node));
731 }
732 }
733 }
734 }
735
736 [DebuggerDisplay("{_key}")]
737 internal sealed class Node : IBinaryTree<T>, IBinaryTree, IEnumerable<T>, IEnumerable
738 {
739 internal static readonly Node EmptyNode = new Node();
740
741 private T _key;
742
743 private bool _frozen;
744
745 private byte _height;
746
747 private int _count;
748
749 private Node _left;
750
751 private Node _right;
752
753 public bool IsEmpty => _left == null;
754
755 public int Height => _height;
756
757 public Node? Left => _left;
758
759 IBinaryTree? IBinaryTree.Left => _left;
760
761 public Node? Right => _right;
762
763 IBinaryTree? IBinaryTree.Right => _right;
764
766
768
769 public T Value => _key;
770
771 public int Count => _count;
772
773 internal T Key => _key;
774
775 internal T this[int index]
776 {
777 get
778 {
779 Requires.Range(index >= 0 && index < Count, "index");
780 if (index < _left._count)
781 {
782 return _left[index];
783 }
784 if (index > _left._count)
785 {
786 return _right[index - _left._count - 1];
787 }
788 return _key;
789 }
790 }
791
792 private int BalanceFactor => _right._height - _left._height;
793
794 private bool IsRightHeavy => BalanceFactor >= 2;
795
796 private bool IsLeftHeavy => BalanceFactor <= -2;
797
798 private bool IsBalanced => (uint)(BalanceFactor + 1) <= 2u;
799
800 private Node()
801 {
802 _frozen = true;
803 }
804
805 private Node(T key, Node left, Node right, bool frozen = false)
806 {
807 Requires.NotNull(left, "left");
808 Requires.NotNull(right, "right");
809 _key = key;
810 _left = left;
811 _right = right;
812 _height = ParentHeight(left, right);
813 _count = ParentCount(left, right);
814 _frozen = frozen;
815 }
816
817 internal ref readonly T ItemRef(int index)
818 {
819 Requires.Range(index >= 0 && index < Count, "index");
820 return ref ItemRefUnchecked(index);
821 }
822
823 private ref readonly T ItemRefUnchecked(int index)
824 {
825 if (index < _left._count)
826 {
828 }
829 if (index > _left._count)
830 {
832 }
833 return ref _key;
834 }
835
837 {
838 return new Enumerator(this);
839 }
840
846
852
854 {
855 return new Enumerator(this, builder);
856 }
857
858 internal static Node NodeTreeFromList(IOrderedCollection<T> items, int start, int length)
859 {
860 Requires.NotNull(items, "items");
861 Requires.Range(start >= 0, "start");
862 Requires.Range(length >= 0, "length");
863 if (length == 0)
864 {
865 return EmptyNode;
866 }
867 int num = (length - 1) / 2;
868 int num2 = length - 1 - num;
869 Node left = NodeTreeFromList(items, start, num2);
870 Node right = NodeTreeFromList(items, start + num2 + 1, num);
871 return new Node(items[start + num2], left, right, frozen: true);
872 }
873
874 internal Node Add(T key)
875 {
876 if (IsEmpty)
877 {
878 return CreateLeaf(key);
879 }
880 Node right = _right.Add(key);
881 Node node = MutateRight(right);
882 if (!node.IsBalanced)
883 {
884 return node.BalanceRight();
885 }
886 return node;
887 }
888
889 internal Node Insert(int index, T key)
890 {
891 Requires.Range(index >= 0 && index <= Count, "index");
892 if (IsEmpty)
893 {
894 return CreateLeaf(key);
895 }
896 if (index <= _left._count)
897 {
898 Node left = _left.Insert(index, key);
899 Node node = MutateLeft(left);
900 if (!node.IsBalanced)
901 {
902 return node.BalanceLeft();
903 }
904 return node;
905 }
906 Node right = _right.Insert(index - _left._count - 1, key);
907 Node node2 = MutateRight(right);
908 if (!node2.IsBalanced)
909 {
910 return node2.BalanceRight();
911 }
912 return node2;
913 }
914
916 {
917 Requires.NotNull(keys, "keys");
918 if (IsEmpty)
919 {
920 return CreateRange(keys);
921 }
922 Node right = _right.AddRange(keys);
923 Node node = MutateRight(right);
924 return node.BalanceMany();
925 }
926
928 {
929 Requires.Range(index >= 0 && index <= Count, "index");
930 Requires.NotNull(keys, "keys");
931 if (IsEmpty)
932 {
933 return CreateRange(keys);
934 }
935 Node node;
936 if (index <= _left._count)
937 {
939 node = MutateLeft(left);
940 }
941 else
942 {
943 Node right = _right.InsertRange(index - _left._count - 1, keys);
944 node = MutateRight(right);
945 }
946 return node.BalanceMany();
947 }
948
949 internal Node RemoveAt(int index)
950 {
951 Requires.Range(index >= 0 && index < Count, "index");
952 Node node = this;
953 if (index == _left._count)
954 {
956 {
957 node = EmptyNode;
958 }
959 else if (_right.IsEmpty && !_left.IsEmpty)
960 {
961 node = _left;
962 }
963 else if (!_right.IsEmpty && _left.IsEmpty)
964 {
965 node = _right;
966 }
967 else
968 {
969 Node node2 = _right;
970 while (!node2._left.IsEmpty)
971 {
972 node2 = node2._left;
973 }
974 Node right = _right.RemoveAt(0);
975 node = node2.MutateBoth(_left, right);
976 }
977 }
978 else if (index < _left._count)
979 {
980 Node left = _left.RemoveAt(index);
981 node = MutateLeft(left);
982 }
983 else
984 {
987 }
988 if (!node.IsEmpty && !node.IsBalanced)
989 {
990 return node.Balance();
991 }
992 return node;
993 }
994
996 {
997 Requires.NotNull(match, "match");
998 Node node = this;
1000 try
1001 {
1002 int num = 0;
1003 while (enumerator.MoveNext())
1004 {
1005 if (match(enumerator.Current))
1006 {
1007 node = node.RemoveAt(num);
1008 enumerator.Dispose();
1009 enumerator = new Enumerator(node, null, num);
1010 }
1011 else
1012 {
1013 num++;
1014 }
1015 }
1016 return node;
1017 }
1018 finally
1019 {
1020 enumerator.Dispose();
1021 }
1022 }
1023
1024 internal Node ReplaceAt(int index, T value)
1025 {
1026 Requires.Range(index >= 0 && index < Count, "index");
1027 Node node = this;
1028 if (index == _left._count)
1029 {
1030 return MutateKey(value);
1031 }
1032 if (index < _left._count)
1033 {
1034 Node left = _left.ReplaceAt(index, value);
1035 return MutateLeft(left);
1036 }
1037 Node right = _right.ReplaceAt(index - _left._count - 1, value);
1038 return MutateRight(right);
1039 }
1040
1041 internal Node Reverse()
1042 {
1043 return Reverse(0, Count);
1044 }
1045
1046 internal Node Reverse(int index, int count)
1047 {
1048 Requires.Range(index >= 0, "index");
1049 Requires.Range(count >= 0, "count");
1050 Requires.Range(index + count <= Count, "index");
1051 Node node = this;
1052 int num = index;
1053 int num2 = index + count - 1;
1054 while (num < num2)
1055 {
1056 T value = node.ItemRef(num);
1057 T value2 = node.ItemRef(num2);
1058 node = node.ReplaceAt(num2, value).ReplaceAt(num, value2);
1059 num++;
1060 num2--;
1061 }
1062 return node;
1063 }
1064
1065 internal Node Sort()
1066 {
1067 return Sort(Comparer<T>.Default);
1068 }
1069
1071 {
1072 Requires.NotNull(comparison, "comparison");
1073 T[] array = new T[Count];
1074 CopyTo(array);
1076 return NodeTreeFromList(array.AsOrderedCollection(), 0, Count);
1077 }
1078
1080 {
1081 return Sort(0, Count, comparer);
1082 }
1083
1085 {
1086 Requires.Range(index >= 0, "index");
1087 Requires.Range(count >= 0, "count");
1089 T[] array = new T[Count];
1090 CopyTo(array);
1092 return NodeTreeFromList(array.AsOrderedCollection(), 0, Count);
1093 }
1094
1095 internal int BinarySearch(int index, int count, T item, IComparer<T>? comparer)
1096 {
1097 Requires.Range(index >= 0, "index");
1098 Requires.Range(count >= 0, "count");
1099 comparer = comparer ?? Comparer<T>.Default;
1100 if (IsEmpty || count <= 0)
1101 {
1102 return ~index;
1103 }
1104 int count2 = _left.Count;
1105 if (index + count <= count2)
1106 {
1108 }
1109 if (index > count2)
1110 {
1111 int num = _right.BinarySearch(index - count2 - 1, count, item, comparer);
1112 int num2 = count2 + 1;
1113 if (num >= 0)
1114 {
1115 return num + num2;
1116 }
1117 return num - num2;
1118 }
1119 int num3 = comparer.Compare(item, _key);
1120 if (num3 == 0)
1121 {
1122 return count2;
1123 }
1124 if (num3 > 0)
1125 {
1126 int num4 = count - (count2 - index) - 1;
1127 int num5 = ((num4 < 0) ? (-1) : _right.BinarySearch(0, num4, item, comparer));
1128 int num6 = count2 + 1;
1129 if (num5 >= 0)
1130 {
1131 return num5 + num6;
1132 }
1133 return num5 - num6;
1134 }
1135 if (index == count2)
1136 {
1137 return ~index;
1138 }
1140 }
1141
1143 {
1144 return IndexOf(item, 0, Count, equalityComparer);
1145 }
1146
1148 {
1149 return Contains(this, item, equalityComparer);
1150 }
1151
1153 {
1154 Requires.Range(index >= 0, "index");
1155 Requires.Range(count >= 0, "count");
1156 Requires.Range(count <= Count, "count");
1157 Requires.Range(index + count <= Count, "count");
1159 using (Enumerator enumerator = new Enumerator(this, null, index, count))
1160 {
1161 while (enumerator.MoveNext())
1162 {
1163 if (equalityComparer.Equals(item, enumerator.Current))
1164 {
1165 return index;
1166 }
1167 index++;
1168 }
1169 }
1170 return -1;
1171 }
1172
1174 {
1175 Requires.Range(index >= 0, "index");
1176 Requires.Range(count >= 0 && count <= Count, "count");
1177 Requires.Argument(index - count + 1 >= 0);
1179 using (Enumerator enumerator = new Enumerator(this, null, index, count, reversed: true))
1180 {
1181 while (enumerator.MoveNext())
1182 {
1183 if (equalityComparer.Equals(item, enumerator.Current))
1184 {
1185 return index;
1186 }
1187 index--;
1188 }
1189 }
1190 return -1;
1191 }
1192
1193 internal void CopyTo(T[] array)
1194 {
1195 Requires.NotNull(array, "array");
1196 Requires.Range(array.Length >= Count, "array");
1197 int num = 0;
1199 while (enumerator.MoveNext())
1200 {
1201 T current = enumerator.Current;
1202 array[num++] = current;
1203 }
1204 }
1205
1206 internal void CopyTo(T[] array, int arrayIndex)
1207 {
1208 Requires.NotNull(array, "array");
1209 Requires.Range(arrayIndex >= 0, "arrayIndex");
1210 Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
1212 while (enumerator.MoveNext())
1213 {
1214 T current = enumerator.Current;
1215 array[arrayIndex++] = current;
1216 }
1217 }
1218
1219 internal void CopyTo(int index, T[] array, int arrayIndex, int count)
1220 {
1221 Requires.NotNull(array, "array");
1222 Requires.Range(index >= 0, "index");
1223 Requires.Range(count >= 0, "count");
1224 Requires.Range(index + count <= Count, "count");
1225 Requires.Range(arrayIndex >= 0, "arrayIndex");
1226 Requires.Range(arrayIndex + count <= array.Length, "arrayIndex");
1227 using Enumerator enumerator = new Enumerator(this, null, index, count);
1228 while (enumerator.MoveNext())
1229 {
1230 array[arrayIndex++] = enumerator.Current;
1231 }
1232 }
1233
1234 internal void CopyTo(Array array, int arrayIndex)
1235 {
1236 Requires.NotNull(array, "array");
1237 Requires.Range(arrayIndex >= 0, "arrayIndex");
1238 Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
1240 while (enumerator.MoveNext())
1241 {
1242 T current = enumerator.Current;
1243 array.SetValue(current, arrayIndex++);
1244 }
1245 }
1246
1248 {
1250 if (IsEmpty)
1251 {
1252 return emptyNode;
1253 }
1254 return emptyNode.AddRange(this.Select(converter));
1255 }
1256
1258 {
1259 Requires.NotNull(match, "match");
1261 {
1262 while (enumerator.MoveNext())
1263 {
1264 T current = enumerator.Current;
1265 if (!match(current))
1266 {
1267 return false;
1268 }
1269 }
1270 }
1271 return true;
1272 }
1273
1275 {
1276 Requires.NotNull(match, "match");
1278 {
1279 while (enumerator.MoveNext())
1280 {
1281 T current = enumerator.Current;
1282 if (match(current))
1283 {
1284 return true;
1285 }
1286 }
1287 }
1288 return false;
1289 }
1290
1292 {
1293 Requires.NotNull(match, "match");
1295 {
1296 while (enumerator.MoveNext())
1297 {
1298 T current = enumerator.Current;
1299 if (match(current))
1300 {
1301 return current;
1302 }
1303 }
1304 }
1305 return default(T);
1306 }
1307
1309 {
1310 Requires.NotNull(match, "match");
1311 if (IsEmpty)
1312 {
1313 return ImmutableList<T>.Empty;
1314 }
1315 List<T> list = null;
1317 {
1318 while (enumerator.MoveNext())
1319 {
1320 T current = enumerator.Current;
1321 if (match(current))
1322 {
1323 if (list == null)
1324 {
1325 list = new List<T>();
1326 }
1327 list.Add(current);
1328 }
1329 }
1330 }
1331 if (list == null)
1332 {
1333 return ImmutableList<T>.Empty;
1334 }
1336 }
1337
1339 {
1340 Requires.NotNull(match, "match");
1341 return FindIndex(0, _count, match);
1342 }
1343
1345 {
1346 Requires.NotNull(match, "match");
1347 Requires.Range(startIndex >= 0 && startIndex <= Count, "startIndex");
1349 }
1350
1352 {
1353 Requires.NotNull(match, "match");
1354 Requires.Range(startIndex >= 0, "startIndex");
1355 Requires.Range(count >= 0, "count");
1356 Requires.Range(startIndex + count <= Count, "count");
1357 using (Enumerator enumerator = new Enumerator(this, null, startIndex, count))
1358 {
1359 int num = startIndex;
1360 while (enumerator.MoveNext())
1361 {
1362 if (match(enumerator.Current))
1363 {
1364 return num;
1365 }
1366 num++;
1367 }
1368 }
1369 return -1;
1370 }
1371
1373 {
1374 Requires.NotNull(match, "match");
1375 using (Enumerator enumerator = new Enumerator(this, null, -1, -1, reversed: true))
1376 {
1377 while (enumerator.MoveNext())
1378 {
1379 if (match(enumerator.Current))
1380 {
1381 return enumerator.Current;
1382 }
1383 }
1384 }
1385 return default(T);
1386 }
1387
1389 {
1390 Requires.NotNull(match, "match");
1391 if (!IsEmpty)
1392 {
1393 return FindLastIndex(Count - 1, Count, match);
1394 }
1395 return -1;
1396 }
1397
1399 {
1400 Requires.NotNull(match, "match");
1401 Requires.Range(startIndex >= 0, "startIndex");
1402 Requires.Range(startIndex == 0 || startIndex < Count, "startIndex");
1403 if (!IsEmpty)
1404 {
1406 }
1407 return -1;
1408 }
1409
1411 {
1412 Requires.NotNull(match, "match");
1413 Requires.Range(startIndex >= 0, "startIndex");
1414 Requires.Range(count <= Count, "count");
1415 Requires.Range(startIndex - count + 1 >= 0, "startIndex");
1416 using (Enumerator enumerator = new Enumerator(this, null, startIndex, count, reversed: true))
1417 {
1418 int num = startIndex;
1419 while (enumerator.MoveNext())
1420 {
1421 if (match(enumerator.Current))
1422 {
1423 return num;
1424 }
1425 num--;
1426 }
1427 }
1428 return -1;
1429 }
1430
1431 internal void Freeze()
1432 {
1433 if (!_frozen)
1434 {
1435 _left.Freeze();
1436 _right.Freeze();
1437 _frozen = true;
1438 }
1439 }
1440
1442 {
1444 }
1445
1447 {
1449 }
1450
1452 {
1453 Node right = _right;
1454 Node left = right._left;
1455 return left.MutateBoth(MutateRight(left._left), right.MutateLeft(left._right));
1456 }
1457
1459 {
1460 Node left = _left;
1461 Node right = left._right;
1462 return right.MutateBoth(left.MutateRight(right._left), MutateLeft(right._right));
1463 }
1464
1465 private Node Balance()
1466 {
1467 if (!IsLeftHeavy)
1468 {
1469 return BalanceRight();
1470 }
1471 return BalanceLeft();
1472 }
1473
1475 {
1476 if (_left.BalanceFactor <= 0)
1477 {
1478 return RotateRight();
1479 }
1480 return DoubleRight();
1481 }
1482
1484 {
1485 if (_right.BalanceFactor >= 0)
1486 {
1487 return RotateLeft();
1488 }
1489 return DoubleLeft();
1490 }
1491
1493 {
1494 Node node = this;
1495 while (!node.IsBalanced)
1496 {
1497 if (node.IsRightHeavy)
1498 {
1499 node = node.BalanceRight();
1500 node.MutateLeft(node._left.BalanceMany());
1501 }
1502 else
1503 {
1504 node = node.BalanceLeft();
1505 node.MutateRight(node._right.BalanceMany());
1506 }
1507 }
1508 return node;
1509 }
1510
1511 private Node MutateBoth(Node left, Node right)
1512 {
1513 Requires.NotNull(left, "left");
1514 Requires.NotNull(right, "right");
1515 if (_frozen)
1516 {
1517 return new Node(_key, left, right);
1518 }
1519 _left = left;
1520 _right = right;
1521 _height = ParentHeight(left, right);
1522 _count = ParentCount(left, right);
1523 return this;
1524 }
1525
1526 private Node MutateLeft(Node left)
1527 {
1528 Requires.NotNull(left, "left");
1529 if (_frozen)
1530 {
1531 return new Node(_key, left, _right);
1532 }
1533 _left = left;
1534 _height = ParentHeight(left, _right);
1535 _count = ParentCount(left, _right);
1536 return this;
1537 }
1538
1539 private Node MutateRight(Node right)
1540 {
1541 Requires.NotNull(right, "right");
1542 if (_frozen)
1543 {
1544 return new Node(_key, _left, right);
1545 }
1546 _right = right;
1547 _height = ParentHeight(_left, right);
1548 _count = ParentCount(_left, right);
1549 return this;
1550 }
1551
1552 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1553 private static byte ParentHeight(Node left, Node right)
1554 {
1555 return checked((byte)(1 + Math.Max(left._height, right._height)));
1556 }
1557
1558 private static int ParentCount(Node left, Node right)
1559 {
1560 return 1 + left._count + right._count;
1561 }
1562
1563 private Node MutateKey(T key)
1564 {
1565 if (_frozen)
1566 {
1567 return new Node(key, _left, _right);
1568 }
1569 _key = key;
1570 return this;
1571 }
1572
1574 {
1576 {
1577 return other._root;
1578 }
1579 IOrderedCollection<T> orderedCollection = keys.AsOrderedCollection();
1581 }
1582
1583 private static Node CreateLeaf(T key)
1584 {
1585 return new Node(key, EmptyNode, EmptyNode);
1586 }
1587
1589 {
1590 if (!node.IsEmpty)
1591 {
1592 if (!equalityComparer.Equals(value, node._key) && !Contains(node._left, value, equalityComparer))
1593 {
1594 return Contains(node._right, value, equalityComparer);
1595 }
1596 return true;
1597 }
1598 return false;
1599 }
1600 }
1601
1602 public static readonly ImmutableList<T> Empty = new ImmutableList<T>();
1603
1604 private readonly Node _root;
1605
1607 public bool IsEmpty => _root.IsEmpty;
1608
1609 public int Count => _root.Count;
1610
1612 object ICollection.SyncRoot => this;
1613
1615 bool ICollection.IsSynchronized => true;
1616
1617 public T this[int index] => _root.ItemRef(index);
1618
1619 T IOrderedCollection<T>.this[int index] => this[index];
1620
1621 T IList<T>.this[int index]
1622 {
1623 get
1624 {
1625 return this[index];
1626 }
1627 set
1628 {
1629 throw new NotSupportedException();
1630 }
1631 }
1632
1634
1635 bool IList.IsFixedSize => true;
1636
1637 bool IList.IsReadOnly => true;
1638
1639 object? IList.this[int index]
1640 {
1641 get
1642 {
1643 return this[index];
1644 }
1645 set
1646 {
1647 throw new NotSupportedException();
1648 }
1649 }
1650
1651 internal Node Root => _root;
1652
1653 internal ImmutableList()
1654 {
1656 }
1657
1658 private ImmutableList(Node root)
1659 {
1660 Requires.NotNull(root, "root");
1661 root.Freeze();
1662 _root = root;
1663 }
1664
1666 {
1667 return Empty;
1668 }
1669
1670 public int BinarySearch(T item)
1671 {
1672 return BinarySearch(item, null);
1673 }
1674
1676 {
1677 return BinarySearch(0, Count, item, comparer);
1678 }
1679
1681 {
1683 }
1684
1686 {
1687 return Clear();
1688 }
1689
1690 public ref readonly T ItemRef(int index)
1691 {
1692 return ref _root.ItemRef(index);
1693 }
1694
1696 {
1697 return new Builder(this);
1698 }
1699
1701 {
1702 Node root = _root.Add(value);
1703 return Wrap(root);
1704 }
1705
1707 {
1708 Requires.NotNull(items, "items");
1709 if (IsEmpty)
1710 {
1711 return CreateRange(items);
1712 }
1713 Node root = _root.AddRange(items);
1714 return Wrap(root);
1715 }
1716
1718 {
1719 Requires.Range(index >= 0 && index <= Count, "index");
1720 return Wrap(_root.Insert(index, item));
1721 }
1722
1724 {
1725 Requires.Range(index >= 0 && index <= Count, "index");
1726 Requires.NotNull(items, "items");
1727 Node root = _root.InsertRange(index, items);
1728 return Wrap(root);
1729 }
1730
1732 {
1734 }
1735
1737 {
1738 int num = this.IndexOf(value, equalityComparer);
1739 if (num >= 0)
1740 {
1741 return RemoveAt(num);
1742 }
1743 return this;
1744 }
1745
1747 {
1748 Requires.Range(index >= 0 && index <= Count, "index");
1749 Requires.Range(count >= 0 && index + count <= Count, "count");
1750 Node node = _root;
1751 int num = count;
1752 while (num-- > 0)
1753 {
1754 node = node.RemoveAt(index);
1755 }
1756 return Wrap(node);
1757 }
1758
1760 {
1762 }
1763
1765 {
1766 Requires.NotNull(items, "items");
1767 if (IsEmpty)
1768 {
1769 return this;
1770 }
1771 Node node = _root;
1772 foreach (T item in items.GetEnumerableDisposable<T, Enumerator>())
1773 {
1774 int num = node.IndexOf(item, equalityComparer);
1775 if (num >= 0)
1776 {
1777 node = node.RemoveAt(num);
1778 }
1779 }
1780 return Wrap(node);
1781 }
1782
1784 {
1785 Requires.Range(index >= 0 && index < Count, "index");
1786 Node root = _root.RemoveAt(index);
1787 return Wrap(root);
1788 }
1789
1791 {
1792 Requires.NotNull(match, "match");
1793 return Wrap(_root.RemoveAll(match));
1794 }
1795
1797 {
1798 return Wrap(_root.ReplaceAt(index, value));
1799 }
1800
1805
1807 {
1808 int num = this.IndexOf(oldValue, equalityComparer);
1809 if (num < 0)
1810 {
1811 throw new ArgumentException(System.SR.CannotFindOldValue, "oldValue");
1812 }
1813 return SetItem(num, newValue);
1814 }
1815
1817 {
1818 return Wrap(_root.Reverse());
1819 }
1820
1822 {
1823 return Wrap(_root.Reverse(index, count));
1824 }
1825
1827 {
1828 return Wrap(_root.Sort());
1829 }
1830
1832 {
1833 Requires.NotNull(comparison, "comparison");
1834 return Wrap(_root.Sort(comparison));
1835 }
1836
1838 {
1839 return Wrap(_root.Sort(comparer));
1840 }
1841
1843 {
1844 Requires.Range(index >= 0, "index");
1845 Requires.Range(count >= 0, "count");
1846 Requires.Range(index + count <= Count, "count");
1847 return Wrap(_root.Sort(index, count, comparer));
1848 }
1849
1851 {
1852 Requires.NotNull(action, "action");
1854 while (enumerator.MoveNext())
1855 {
1856 T current = enumerator.Current;
1857 action(current);
1858 }
1859 }
1860
1861 public void CopyTo(T[] array)
1862 {
1864 }
1865
1866 public void CopyTo(T[] array, int arrayIndex)
1867 {
1869 }
1870
1871 public void CopyTo(int index, T[] array, int arrayIndex, int count)
1872 {
1874 }
1875
1877 {
1878 Requires.Range(index >= 0, "index");
1879 Requires.Range(count >= 0, "count");
1880 Requires.Range(index + count <= Count, "count");
1881 return Wrap(Node.NodeTreeFromList(this, index, count));
1882 }
1883
1885 {
1886 Requires.NotNull(converter, "converter");
1887 return ImmutableList<TOutput>.WrapNode(_root.ConvertAll(converter));
1888 }
1889
1891 {
1892 return _root.Exists(match);
1893 }
1894
1896 {
1897 return _root.Find(match);
1898 }
1899
1901 {
1902 return _root.FindAll(match);
1903 }
1904
1906 {
1907 return _root.FindIndex(match);
1908 }
1909
1911 {
1913 }
1914
1916 {
1918 }
1919
1921 {
1922 return _root.FindLast(match);
1923 }
1924
1926 {
1927 return _root.FindLastIndex(match);
1928 }
1929
1931 {
1933 }
1934
1936 {
1938 }
1939
1941 {
1943 }
1944
1949
1951 {
1952 return _root.TrueForAll(match);
1953 }
1954
1955 public bool Contains(T value)
1956 {
1958 }
1959
1960 public int IndexOf(T value)
1961 {
1962 return this.IndexOf(value, EqualityComparer<T>.Default);
1963 }
1964
1966 {
1967 return Add(value);
1968 }
1969
1971 {
1972 return AddRange(items);
1973 }
1974
1976 {
1977 return Insert(index, item);
1978 }
1979
1981 {
1982 return InsertRange(index, items);
1983 }
1984
1989
1994
1999
2001 {
2002 return RemoveRange(index, count);
2003 }
2004
2006 {
2007 return RemoveAt(index);
2008 }
2009
2011 {
2012 return SetItem(index, value);
2013 }
2014
2019
2021 {
2022 if (!IsEmpty)
2023 {
2024 return GetEnumerator();
2025 }
2026 return Enumerable.Empty<T>().GetEnumerator();
2027 }
2028
2030 {
2031 return GetEnumerator();
2032 }
2033
2034 void IList<T>.Insert(int index, T item)
2035 {
2036 throw new NotSupportedException();
2037 }
2038
2039 void IList<T>.RemoveAt(int index)
2040 {
2041 throw new NotSupportedException();
2042 }
2043
2045 {
2046 throw new NotSupportedException();
2047 }
2048
2050 {
2051 throw new NotSupportedException();
2052 }
2053
2055 {
2056 throw new NotSupportedException();
2057 }
2058
2063
2064 int IList.Add(object value)
2065 {
2066 throw new NotSupportedException();
2067 }
2068
2070 {
2071 throw new NotSupportedException();
2072 }
2073
2075 {
2076 throw new NotSupportedException();
2077 }
2078
2079 bool IList.Contains(object value)
2080 {
2082 {
2083 return Contains((T)value);
2084 }
2085 return false;
2086 }
2087
2088 int IList.IndexOf(object value)
2089 {
2091 {
2092 return -1;
2093 }
2094 return IndexOf((T)value);
2095 }
2096
2097 void IList.Insert(int index, object value)
2098 {
2099 throw new NotSupportedException();
2100 }
2101
2102 void IList.Remove(object value)
2103 {
2104 throw new NotSupportedException();
2105 }
2106
2108 {
2109 return new Enumerator(_root);
2110 }
2111
2112 private static ImmutableList<T> WrapNode(Node root)
2113 {
2114 if (!root.IsEmpty)
2115 {
2116 return new ImmutableList<T>(root);
2117 }
2118 return Empty;
2119 }
2120
2122 {
2124 if (other != null)
2125 {
2126 return true;
2127 }
2129 {
2130 other = builder.ToImmutable();
2131 return true;
2132 }
2133 return false;
2134 }
2135
2136 private static bool IsCompatibleObject(object value)
2137 {
2138 if (!(value is T))
2139 {
2140 if (value == null)
2141 {
2142 return default(T) == null;
2143 }
2144 return false;
2145 }
2146 return true;
2147 }
2148
2150 {
2151 if (root != _root)
2152 {
2153 if (!root.IsEmpty)
2154 {
2155 return new ImmutableList<T>(root);
2156 }
2157 return Clear();
2158 }
2159 return this;
2160 }
2161
2163 {
2164 if (TryCastToImmutableList(items, out var other))
2165 {
2166 return other;
2167 }
2168 IOrderedCollection<T> orderedCollection = items.AsOrderedCollection();
2169 if (orderedCollection.Count == 0)
2170 {
2171 return Empty;
2172 }
2174 return new ImmutableList<T>(root);
2175 }
2176}
static void Sort(Array array)
Definition Array.cs:2329
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
void InsertRange(int index, IEnumerable< T > items)
int FindLastIndex(int startIndex, int count, Predicate< T > match)
int BinarySearch(int index, int count, T item, IComparer< T >? comparer)
ImmutableList< T > GetRange(int index, int count)
void Sort(int index, int count, IComparer< T >? comparer)
int IndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
int LastIndexOf(T item, int startIndex, int count, IEqualityComparer< T >? equalityComparer)
ImmutableList< T >.Enumerator GetEnumerator()
int FindIndex(int startIndex, int count, Predicate< T > match)
ImmutableList< TOutput > ConvertAll< TOutput >(Func< T, TOutput > converter)
int IndexOf(T item, int index, int count)
int BinarySearch(T item, IComparer< T >? comparer)
int FindLastIndex(int startIndex, Predicate< T > match)
ImmutableList< T > FindAll(Predicate< T > match)
int FindIndex(int startIndex, Predicate< T > match)
void CopyTo(int index, T[] array, int arrayIndex, int count)
int LastIndexOf(T item, int startIndex, int count)
int BinarySearch(int index, int count, T item, IComparer< T >? comparer)
static bool Contains(Node node, T value, IEqualityComparer< T > equalityComparer)
int LastIndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
int FindLastIndex(int startIndex, int count, Predicate< T > match)
int IndexOf(T item, IEqualityComparer< T >? equalityComparer)
int FindLastIndex(int startIndex, Predicate< T > match)
ImmutableList< T > FindAll(Predicate< T > match)
static Node NodeTreeFromList(IOrderedCollection< T > items, int start, int length)
int FindIndex(int startIndex, Predicate< T > match)
static byte ParentHeight(Node left, Node right)
Node Sort(int index, int count, IComparer< T >? comparer)
int IndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
Node InsertRange(int index, IEnumerable< T > keys)
int FindIndex(int startIndex, int count, Predicate< T > match)
void CopyTo(Array array, int arrayIndex)
static int ParentCount(Node left, Node right)
void CopyTo(int index, T[] array, int arrayIndex, int count)
static Node CreateRange(IEnumerable< T > keys)
ImmutableList< TOutput >.Node ConvertAll< TOutput >(Func< T, TOutput > converter)
bool Contains(T item, IEqualityComparer< T > equalityComparer)
Node(T key, Node left, Node right, bool frozen=false)
ImmutableList< T > Sort(Comparison< T > comparison)
ImmutableList< T > Insert(int index, T item)
ImmutableList< T > InsertRange(int index, IEnumerable< T > items)
ImmutableList< T > RemoveAt(int index)
ImmutableList< T > RemoveAll(Predicate< T > match)
int IndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
static ImmutableList< TSource > ToImmutableList< TSource >(this IEnumerable< TSource > source)
ImmutableList< T > Replace(T oldValue, T newValue)
int FindLastIndex(int startIndex, Predicate< T > match)
int FindIndex(int startIndex, int count, Predicate< T > match)
ImmutableList< T > GetRange(int index, int count)
int FindLastIndex(int startIndex, int count, Predicate< T > match)
static int IndexOf< T >(this IImmutableList< T > list, T item)
static readonly ImmutableList< T > Empty
IEnumerator< T > IEnumerable< T >. GetEnumerator()
static int LastIndexOf< T >(this IImmutableList< T > list, T item)
ImmutableList< T > RemoveRange(int index, int count)
static ImmutableList< T > CreateRange< T >(IEnumerable< T > items)
static ImmutableList< T > CreateRange(IEnumerable< T > items)
int BinarySearch(int index, int count, T item, IComparer< T >? comparer)
static ImmutableList< T >.Builder CreateBuilder< T >()
ImmutableList< T > FindAll(Predicate< T > match)
int BinarySearch(T item, IComparer< T >? comparer)
ImmutableList< T > Remove(T value, IEqualityComparer< T >? equalityComparer)
ImmutableList< T > AddRange(IEnumerable< T > items)
static ImmutableList< T > Create< T >()
ImmutableList< T > Replace(T oldValue, T newValue, IEqualityComparer< T >? equalityComparer)
ImmutableList< T > Sort(int index, int count, IComparer< T >? comparer)
static bool TryCastToImmutableList(IEnumerable< T > sequence, [NotNullWhen(true)] out ImmutableList< T > other)
ImmutableList< T > Sort(IComparer< T >? comparer)
static IImmutableList< T > Remove< T >(this IImmutableList< T > list, T value)
ImmutableList< T > RemoveRange(IEnumerable< T > items)
void CopyTo(T[] array, int arrayIndex)
static IImmutableList< T > RemoveRange< T >(this IImmutableList< T > list, IEnumerable< T > items)
int LastIndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
static bool IsCompatibleObject(object value)
void CopyTo(int index, T[] array, int arrayIndex, int count)
ImmutableList< T > SetItem(int index, T value)
ImmutableList< TOutput > ConvertAll< TOutput >(Func< T, TOutput > converter)
ImmutableList< T > Reverse(int index, int count)
int FindIndex(int startIndex, Predicate< T > match)
static ImmutableList< T > WrapNode(Node root)
static IImmutableList< T > Replace< T >(this IImmutableList< T > list, T oldValue, T newValue)
ImmutableList< T > RemoveRange(IEnumerable< T > items, IEqualityComparer< T >? equalityComparer)
static void Range(bool condition, string? parameterName, string? message=null)
Definition Requires.cs:40
static void Argument(bool condition, string? parameterName, string? message)
Definition Requires.cs:59
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static string CollectionModifiedDuringEnumeration
Definition SR.cs:26
static string CannotFindOldValue
Definition SR.cs:20
Definition SR.cs:7
static int CompareExchange(ref int location1, int value, int comparand)
void CopyTo(Array array, int index)
void RemoveAt(int index)
void Insert(int index, object? value)
int Add(object? value)
bool Contains(object? value)
void Remove(object? value)
int IndexOf(object? value)
SecurePooledObject< Stack< RefAsValueType< Node > > > _stack
static readonly SecureObjectPool< Stack< RefAsValueType< Node > >, Enumerator > s_EnumeratingStacks
Enumerator(Node root, Builder? builder=null, int startIndex=-1, int count=-1, bool reversed=false)