Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ImmutableHashSet.cs
Go to the documentation of this file.
4using System.Linq;
5
7
8[DebuggerDisplay("Count = {Count}")]
10public sealed class ImmutableHashSet<T> : IImmutableSet<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IHashKeyCollection<T>, ICollection<T>, ISet<T>, ICollection, IStrongEnumerable<T, ImmutableHashSet<T>.Enumerator>, IReadOnlySet<T>
11{
36
37 private sealed class HashBucketByRefEqualityComparer : IEqualityComparer<HashBucket>
38 {
40
42
46
47 public bool Equals(HashBucket x, HashBucket y)
48 {
49 return x.EqualsByRef(y);
50 }
51
53 {
54 throw new NotSupportedException();
55 }
56 }
57
58 [DebuggerDisplay("Count = {Count}")]
59 public sealed class Builder : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, ISet<T>, ICollection<T>
60 {
62
64
66
67 private int _count;
68
70
71 private int _version;
72
73 public int Count => _count;
74
76
78 {
79 get
80 {
81 return _equalityComparer;
82 }
83 set
84 {
85 Requires.NotNull(value, "value");
87 {
89 _immutable = null;
91 Root = mutationResult.Root;
93 }
94 }
95 }
96
97 internal int Version => _version;
98
100
102 {
103 get
104 {
105 return _root;
106 }
107 set
108 {
109 _version++;
110 if (_root != value)
111 {
112 _root = value;
113 _immutable = null;
114 }
115 }
116 }
117
119 {
120 Requires.NotNull(set, "set");
121 _root = set._root;
122 _count = set._count;
123 _equalityComparer = set._equalityComparer;
124 _hashBucketEqualityComparer = set._hashBucketEqualityComparer;
125 _immutable = set;
126 }
127
129 {
130 return new Enumerator(_root, this);
131 }
132
134 {
135 if (_immutable == null)
136 {
138 }
139 return _immutable;
140 }
141
143 {
144 int key = ((equalValue != null) ? _equalityComparer.GetHashCode(equalValue) : 0);
146 {
147 return value.TryExchange(equalValue, _equalityComparer, out actualValue);
148 }
150 return false;
151 }
152
153 public bool Add(T item)
154 {
156 Apply(result);
157 return result.Count != 0;
158 }
159
160 public bool Remove(T item)
161 {
163 Apply(result);
164 return result.Count != 0;
165 }
166
167 public bool Contains(T item)
168 {
170 }
171
172 public void Clear()
173 {
174 _count = 0;
176 }
177
183
185 {
186 MutationResult result = ImmutableHashSet<T>.Intersect(other, Origin);
187 Apply(result);
188 }
189
191 {
192 return ImmutableHashSet<T>.IsProperSubsetOf(other, Origin);
193 }
194
196 {
197 return ImmutableHashSet<T>.IsProperSupersetOf(other, Origin);
198 }
199
201 {
202 return ImmutableHashSet<T>.IsSubsetOf(other, Origin);
203 }
204
206 {
207 return ImmutableHashSet<T>.IsSupersetOf(other, Origin);
208 }
209
211 {
212 return ImmutableHashSet<T>.Overlaps(other, Origin);
213 }
214
216 {
217 if (this == other)
218 {
219 return true;
220 }
221 return ImmutableHashSet<T>.SetEquals(other, Origin);
222 }
223
225 {
226 MutationResult result = ImmutableHashSet<T>.SymmetricExcept(other, Origin);
227 Apply(result);
228 }
229
231 {
233 Apply(result);
234 }
235
237 {
238 Add(item);
239 }
240
242 {
243 Requires.NotNull(array, "array");
244 Requires.Range(arrayIndex >= 0, "arrayIndex");
245 Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
247 while (enumerator.MoveNext())
248 {
249 T current = enumerator.Current;
250 array[arrayIndex++] = current;
251 }
252 }
253
258
263
264 private void Apply(MutationResult result)
265 {
266 Root = result.Root;
267 if (result.CountType == CountType.Adjustment)
268 {
269 _count += result.Count;
270 }
271 else
272 {
273 _count = result.Count;
274 }
275 }
276 }
277
279 {
280 private readonly Builder _builder;
281
283
285
287
288 public T Current
289 {
290 get
291 {
292 _mapEnumerator.ThrowIfDisposed();
293 return _bucketEnumerator.Current;
294 }
295 }
296
297 object? IEnumerator.Current => Current;
298
306
307 public bool MoveNext()
308 {
310 if (_bucketEnumerator.MoveNext())
311 {
312 return true;
313 }
314 if (_mapEnumerator.MoveNext())
315 {
317 return _bucketEnumerator.MoveNext();
318 }
319 return false;
320 }
321
322 public void Reset()
323 {
325 _mapEnumerator.Reset();
326 _bucketEnumerator.Dispose();
328 }
329
330 public void Dispose()
331 {
332 _mapEnumerator.Dispose();
333 _bucketEnumerator.Dispose();
334 }
335
343 }
344
345 internal enum OperationResult
346 {
349 }
350
351 internal readonly struct HashBucket
352 {
354 {
355 private enum Position
356 {
358 First,
360 End
361 }
362
363 private readonly HashBucket _bucket;
364
365 private bool _disposed;
366
368
370
371 object? IEnumerator.Current => Current;
372
373 public T Current
374 {
375 get
376 {
378 return _currentPosition switch
379 {
380 Position.First => _bucket._firstValue,
381 Position.Additional => _additionalEnumerator.Current,
382 _ => throw new InvalidOperationException(),
383 };
384 }
385 }
386
387 internal Enumerator(HashBucket bucket)
388 {
389 _disposed = false;
390 _bucket = bucket;
391 _currentPosition = Position.BeforeFirst;
393 }
394
395 public bool MoveNext()
396 {
398 if (_bucket.IsEmpty)
399 {
401 return false;
402 }
403 switch (_currentPosition)
404 {
405 case Position.BeforeFirst:
407 return true;
408 case Position.First:
409 if (_bucket._additionalElements.IsEmpty)
410 {
412 return false;
413 }
414 _currentPosition = Position.Additional;
416 return _additionalEnumerator.MoveNext();
417 case Position.Additional:
418 return _additionalEnumerator.MoveNext();
419 case Position.End:
420 return false;
421 default:
422 throw new InvalidOperationException();
423 }
424 }
425
426 public void Reset()
427 {
429 _additionalEnumerator.Dispose();
430 _currentPosition = Position.BeforeFirst;
431 }
432
433 public void Dispose()
434 {
435 _disposed = true;
436 _additionalEnumerator.Dispose();
437 }
438
439 private void ThrowIfDisposed()
440 {
441 if (_disposed)
442 {
443 Requires.FailObjectDisposed(this);
444 }
445 }
446 }
447
448 private readonly T _firstValue;
449
451
452 internal bool IsEmpty => _additionalElements == null;
453
459
461 {
462 return new Enumerator(this);
463 }
464
465 public override bool Equals(object? obj)
466 {
467 throw new NotSupportedException();
468 }
469
470 public override int GetHashCode()
471 {
472 throw new NotSupportedException();
473 }
474
476 {
477 if ((object)_firstValue == (object)other._firstValue)
478 {
479 return _additionalElements == other._additionalElements;
480 }
481 return false;
482 }
483
485 {
486 if (valueComparer.Equals(_firstValue, other._firstValue))
487 {
488 return _additionalElements == other._additionalElements;
489 }
490 return false;
491 }
492
494 {
495 if (IsEmpty)
496 {
497 result = OperationResult.SizeChanged;
498 return new HashBucket(value);
499 }
501 {
502 result = OperationResult.NoChangeRequired;
503 return this;
504 }
505 result = OperationResult.SizeChanged;
507 }
508
510 {
511 if (IsEmpty)
512 {
513 return false;
514 }
515 if (!valueComparer.Equals(value, _firstValue))
516 {
517 return _additionalElements.IndexOf(value, valueComparer) >= 0;
518 }
519 return true;
520 }
521
523 {
524 if (!IsEmpty)
525 {
526 if (valueComparer.Equals(value, _firstValue))
527 {
529 return true;
530 }
531 int num = _additionalElements.IndexOf(value, valueComparer);
532 if (num >= 0)
533 {
534 existingValue = _additionalElements.ItemRef(num);
535 return true;
536 }
537 }
539 return false;
540 }
541
543 {
544 if (IsEmpty)
545 {
546 result = OperationResult.NoChangeRequired;
547 return this;
548 }
550 {
551 if (_additionalElements.IsEmpty)
552 {
553 result = OperationResult.SizeChanged;
554 return default(HashBucket);
555 }
556 int count = _additionalElements.Left.Count;
557 result = OperationResult.SizeChanged;
558 return new HashBucket(_additionalElements.Key, _additionalElements.RemoveAt(count));
559 }
560 int num = _additionalElements.IndexOf(value, equalityComparer);
561 if (num < 0)
562 {
563 result = OperationResult.NoChangeRequired;
564 return this;
565 }
566 result = OperationResult.SizeChanged;
567 return new HashBucket(_firstValue, _additionalElements.RemoveAt(num));
568 }
569
570 internal void Freeze()
571 {
572 if (_additionalElements != null)
573 {
574 _additionalElements.Freeze();
575 }
576 }
577 }
578
579 private readonly struct MutationInput
580 {
582
584
585 private readonly int _count;
586
588
590
592
593 internal int Count => _count;
594
596
598 {
599 Requires.NotNull(set, "set");
600 _root = set._root;
601 _equalityComparer = set._equalityComparer;
602 _count = set._count;
603 _hashBucketEqualityComparer = set._hashBucketEqualityComparer;
604 }
605
617 }
618
619 private enum CountType
620 {
621 Adjustment,
623 }
624
625 private readonly struct MutationResult
626 {
628
629 private readonly int _count;
630
631 private readonly CountType _countType;
632
634
635 internal int Count => _count;
636
638
640 {
641 Requires.NotNull(root, "root");
642 _root = root;
643 _count = count;
645 }
646
648 {
649 Requires.NotNull(priorSet, "priorSet");
650 int num = Count;
651 if (CountType == CountType.Adjustment)
652 {
653 num += priorSet._count;
654 }
655 return priorSet.Wrap(Root, num);
656 }
657 }
658
659 private readonly struct NodeEnumerable : IEnumerable<T>, IEnumerable
660 {
662
664 {
665 Requires.NotNull(root, "root");
666 _root = root;
667 }
668
670 {
671 return new Enumerator(_root);
672 }
673
679
685 }
686
688
690 {
691 kv.Value.Freeze();
692 };
693
695
696 private readonly int _count;
697
699
701
702 public int Count => _count;
703
704 public bool IsEmpty => Count == 0;
705
707
709 object ICollection.SyncRoot => this;
710
712 bool ICollection.IsSynchronized => true;
713
714 internal IBinaryTree Root => _root;
715
716 private MutationInput Origin => new MutationInput(this);
717
719
724
735
737 {
738 if (!IsEmpty)
739 {
740 return Empty.WithComparer(_equalityComparer);
741 }
742 return this;
743 }
744
746 {
747 return Clear();
748 }
749
751 {
752 return new Builder(this);
753 }
754
756 {
757 return Add(item, Origin).Finalize(this);
758 }
759
761 {
762 return Remove(item, Origin).Finalize(this);
763 }
764
766 {
767 int key = ((equalValue != null) ? _equalityComparer.GetHashCode(equalValue) : 0);
769 {
770 return value.TryExchange(equalValue, _equalityComparer, out actualValue);
771 }
773 return false;
774 }
775
777 {
778 Requires.NotNull(other, "other");
779 return Union(other, avoidWithComparer: false);
780 }
781
783 {
784 Requires.NotNull(other, "other");
785 return Intersect(other, Origin).Finalize(this);
786 }
787
789 {
790 Requires.NotNull(other, "other");
792 }
793
795 {
796 Requires.NotNull(other, "other");
797 return SymmetricExcept(other, Origin).Finalize(this);
798 }
799
801 {
802 Requires.NotNull(other, "other");
803 if (this == other)
804 {
805 return true;
806 }
807 return SetEquals(other, Origin);
808 }
809
811 {
812 Requires.NotNull(other, "other");
814 }
815
817 {
818 Requires.NotNull(other, "other");
820 }
821
823 {
824 Requires.NotNull(other, "other");
825 return IsSubsetOf(other, Origin);
826 }
827
829 {
830 Requires.NotNull(other, "other");
831 return IsSupersetOf(other, Origin);
832 }
833
835 {
836 Requires.NotNull(other, "other");
837 return Overlaps(other, Origin);
838 }
839
841 {
842 return Add(item);
843 }
844
849
854
859
864
869
870 public bool Contains(T item)
871 {
872 return Contains(item, Origin);
873 }
874
888
890 {
891 throw new NotSupportedException();
892 }
893
894 void ISet<T>.ExceptWith(IEnumerable<T> other)
895 {
896 throw new NotSupportedException();
897 }
898
899 void ISet<T>.IntersectWith(IEnumerable<T> other)
900 {
901 throw new NotSupportedException();
902 }
903
904 void ISet<T>.SymmetricExceptWith(IEnumerable<T> other)
905 {
906 throw new NotSupportedException();
907 }
908
910 {
911 throw new NotSupportedException();
912 }
913
915 {
916 Requires.NotNull(array, "array");
917 Requires.Range(arrayIndex >= 0, "arrayIndex");
918 Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
920 while (enumerator.MoveNext())
921 {
922 T current = enumerator.Current;
923 array[arrayIndex++] = current;
924 }
925 }
926
928 {
929 throw new NotSupportedException();
930 }
931
933 {
934 throw new NotSupportedException();
935 }
936
938 {
939 throw new NotSupportedException();
940 }
941
943 {
944 Requires.NotNull(array, "array");
945 Requires.Range(arrayIndex >= 0, "arrayIndex");
946 Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
948 while (enumerator.MoveNext())
949 {
950 T current = enumerator.Current;
951 array.SetValue(current, arrayIndex++);
952 }
953 }
954
956 {
957 return new Enumerator(_root);
958 }
959
961 {
962 if (!IsEmpty)
963 {
964 return GetEnumerator();
965 }
966 return Enumerable.Empty<T>().GetEnumerator();
967 }
968
973
974 private static bool IsSupersetOf(IEnumerable<T> other, MutationInput origin)
975 {
976 Requires.NotNull(other, "other");
977 foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
978 {
979 if (!Contains(item, origin))
980 {
981 return false;
982 }
983 }
984 return true;
985 }
986
987 private static MutationResult Add(T item, MutationInput origin)
988 {
989 int num = ((item != null) ? origin.EqualityComparer.GetHashCode(item) : 0);
990 OperationResult result;
991 HashBucket newBucket = origin.Root.GetValueOrDefault(num).Add(item, origin.EqualityComparer, out result);
992 if (result == OperationResult.NoChangeRequired)
993 {
994 return new MutationResult(origin.Root, 0);
995 }
997 return new MutationResult(root, 1);
998 }
999
1000 private static MutationResult Remove(T item, MutationInput origin)
1001 {
1002 OperationResult result = OperationResult.NoChangeRequired;
1003 int num = ((item != null) ? origin.EqualityComparer.GetHashCode(item) : 0);
1005 if (origin.Root.TryGetValue(num, out var value))
1006 {
1008 if (result == OperationResult.NoChangeRequired)
1009 {
1010 return new MutationResult(origin.Root, 0);
1011 }
1012 root = UpdateRoot(origin.Root, num, origin.HashBucketEqualityComparer, newBucket);
1013 }
1014 return new MutationResult(root, (result == OperationResult.SizeChanged) ? (-1) : 0);
1015 }
1016
1017 private static bool Contains(T item, MutationInput origin)
1018 {
1019 int key = ((item != null) ? origin.EqualityComparer.GetHashCode(item) : 0);
1020 if (origin.Root.TryGetValue(key, out var value))
1021 {
1022 return value.Contains(item, origin.EqualityComparer);
1023 }
1024 return false;
1025 }
1026
1028 {
1029 Requires.NotNull(other, "other");
1030 int num = 0;
1032 foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
1033 {
1034 int num2 = ((item != null) ? origin.EqualityComparer.GetHashCode(item) : 0);
1035 OperationResult result;
1036 HashBucket newBucket = sortedInt32KeyNode.GetValueOrDefault(num2).Add(item, origin.EqualityComparer, out result);
1037 if (result == OperationResult.SizeChanged)
1038 {
1039 sortedInt32KeyNode = UpdateRoot(sortedInt32KeyNode, num2, origin.HashBucketEqualityComparer, newBucket);
1040 num++;
1041 }
1042 }
1043 return new MutationResult(sortedInt32KeyNode, num);
1044 }
1045
1046 private static bool Overlaps(IEnumerable<T> other, MutationInput origin)
1047 {
1048 Requires.NotNull(other, "other");
1049 if (origin.Root.IsEmpty)
1050 {
1051 return false;
1052 }
1053 foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
1054 {
1055 if (Contains(item, origin))
1056 {
1057 return true;
1058 }
1059 }
1060 return false;
1061 }
1062
1063 private static bool SetEquals(IEnumerable<T> other, MutationInput origin)
1064 {
1065 Requires.NotNull(other, "other");
1067 if (origin.Count != hashSet.Count)
1068 {
1069 return false;
1070 }
1071 foreach (T item in hashSet)
1072 {
1073 if (!Contains(item, origin))
1074 {
1075 return false;
1076 }
1077 }
1078 return true;
1079 }
1080
1082 {
1083 bool mutated;
1084 if (newBucket.IsEmpty)
1085 {
1086 return root.Remove(hashCode, out mutated);
1087 }
1089 return root.SetItem(hashCode, newBucket, hashBucketEqualityComparer, out replacedExistingValue, out mutated);
1090 }
1091
1093 {
1094 Requires.NotNull(other, "other");
1096 int num = 0;
1097 foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
1098 {
1099 if (Contains(item, origin))
1100 {
1101 MutationResult mutationResult = Add(item, new MutationInput(root, origin.EqualityComparer, origin.HashBucketEqualityComparer, num));
1102 root = mutationResult.Root;
1103 num += mutationResult.Count;
1104 }
1105 }
1106 return new MutationResult(root, num, CountType.FinalValue);
1107 }
1108
1110 {
1111 Requires.NotNull(other, "other");
1112 Requires.NotNull(equalityComparer, "equalityComparer");
1113 Requires.NotNull(root, "root");
1114 int num = 0;
1116 foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
1117 {
1118 int num2 = ((item != null) ? equalityComparer.GetHashCode(item) : 0);
1120 {
1121 OperationResult result;
1123 if (result == OperationResult.SizeChanged)
1124 {
1125 num--;
1127 }
1128 }
1129 }
1130 return new MutationResult(sortedInt32KeyNode, num);
1131 }
1132
1134 {
1135 Requires.NotNull(other, "other");
1137 int num = 0;
1139 foreach (T item in new NodeEnumerable(origin.Root))
1140 {
1142 {
1143 MutationResult mutationResult = Add(item, new MutationInput(root, origin.EqualityComparer, origin.HashBucketEqualityComparer, num));
1144 root = mutationResult.Root;
1145 num += mutationResult.Count;
1146 }
1147 }
1148 foreach (T item2 in immutableHashSet)
1149 {
1150 if (!Contains(item2, origin))
1151 {
1152 MutationResult mutationResult2 = Add(item2, new MutationInput(root, origin.EqualityComparer, origin.HashBucketEqualityComparer, num));
1153 root = mutationResult2.Root;
1154 num += mutationResult2.Count;
1155 }
1156 }
1157 return new MutationResult(root, num, CountType.FinalValue);
1158 }
1159
1161 {
1162 Requires.NotNull(other, "other");
1163 if (origin.Root.IsEmpty)
1164 {
1165 return other.Any();
1166 }
1168 if (origin.Count >= hashSet.Count)
1169 {
1170 return false;
1171 }
1172 int num = 0;
1173 bool flag = false;
1174 foreach (T item in hashSet)
1175 {
1176 if (Contains(item, origin))
1177 {
1178 num++;
1179 }
1180 else
1181 {
1182 flag = true;
1183 }
1184 if (num == origin.Count && flag)
1185 {
1186 return true;
1187 }
1188 }
1189 return false;
1190 }
1191
1193 {
1194 Requires.NotNull(other, "other");
1195 if (origin.Root.IsEmpty)
1196 {
1197 return false;
1198 }
1199 int num = 0;
1200 foreach (T item in other.GetEnumerableDisposable<T, Enumerator>())
1201 {
1202 num++;
1203 if (!Contains(item, origin))
1204 {
1205 return false;
1206 }
1207 }
1208 return origin.Count > num;
1209 }
1210
1211 private static bool IsSubsetOf(IEnumerable<T> other, MutationInput origin)
1212 {
1213 Requires.NotNull(other, "other");
1214 if (origin.Root.IsEmpty)
1215 {
1216 return true;
1217 }
1219 int num = 0;
1220 foreach (T item in hashSet)
1221 {
1222 if (Contains(item, origin))
1223 {
1224 num++;
1225 }
1226 }
1227 return num == origin.Count;
1228 }
1229
1231 {
1232 Requires.NotNull(root, "root");
1233 Requires.NotNull(equalityComparer, "equalityComparer");
1234 Requires.Range(count >= 0, "count");
1235 return new ImmutableHashSet<T>(root, equalityComparer, count);
1236 }
1237
1250
1252 {
1253 if (root == _root)
1254 {
1255 return this;
1256 }
1258 }
1259
1261 {
1262 Requires.NotNull(items, "items");
1264 {
1265 return immutableHashSet.WithComparer(KeyComparer);
1266 }
1267 return Union(items, Origin).Finalize(this);
1268 }
1269}
1270public static class ImmutableHashSet
1271{
1273 {
1274 return ImmutableHashSet<T>.Empty;
1275 }
1276
1278 {
1279 return ImmutableHashSet<T>.Empty.WithComparer(equalityComparer);
1280 }
1281
1283 {
1284 return ImmutableHashSet<T>.Empty.Add(item);
1285 }
1286
1288 {
1289 return ImmutableHashSet<T>.Empty.WithComparer(equalityComparer).Add(item);
1290 }
1291
1293 {
1294 return ImmutableHashSet<T>.Empty.Union(items);
1295 }
1296
1298 {
1299 return ImmutableHashSet<T>.Empty.WithComparer(equalityComparer).Union(items);
1300 }
1301
1302 public static ImmutableHashSet<T> Create<T>(params T[] items)
1303 {
1304 return ImmutableHashSet<T>.Empty.Union(items);
1305 }
1306
1308 {
1309 return ImmutableHashSet<T>.Empty.WithComparer(equalityComparer).Union(items);
1310 }
1311
1313 {
1314 return Create<T>().ToBuilder();
1315 }
1316
1318 {
1319 return Create(equalityComparer).ToBuilder();
1320 }
1321
1330
1332 {
1333 Requires.NotNull(builder, "builder");
1334 return builder.ToImmutable();
1335 }
1336
1338 {
1339 return source.ToImmutableHashSet(null);
1340 }
1341}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
bool TryGetValue(T equalValue, out T actualValue)
readonly IEqualityComparer< HashBucket > _hashBucketEqualityComparer
static ImmutableHashSet< T > Wrap(SortedInt32KeyNode< HashBucket > root, IEqualityComparer< T > equalityComparer, int count)
static readonly Action< KeyValuePair< int, HashBucket > > s_FreezeBucketAction
readonly IEqualityComparer< HashBucket > _hashBucketEqualityComparer
static bool Overlaps(IEnumerable< T > other, MutationInput origin)
static MutationResult Except(IEnumerable< T > other, IEqualityComparer< T > equalityComparer, IEqualityComparer< HashBucket > hashBucketEqualityComparer, SortedInt32KeyNode< HashBucket > root)
static IEqualityComparer< HashBucket > GetHashBucketEqualityComparer(IEqualityComparer< T > valueComparer)
static bool IsSubsetOf(IEnumerable< T > other, MutationInput origin)
bool TryGetValue(T equalValue, out T actualValue)
bool IsProperSupersetOf(IEnumerable< T > other)
ImmutableHashSet< T > Union(IEnumerable< T > other)
ImmutableHashSet< T > Intersect(IEnumerable< T > other)
ImmutableHashSet< T > Wrap(SortedInt32KeyNode< HashBucket > root, int adjustedCountIfDifferentRoot)
static ImmutableHashSet< T > CreateRange< T >(IEnumerable< T > items)
static MutationResult Union(IEnumerable< T > other, MutationInput origin)
static MutationResult Add(T item, MutationInput origin)
ImmutableHashSet< T > Union(IEnumerable< T > items, bool avoidWithComparer)
static ImmutableHashSet< T >.Builder CreateBuilder< T >()
static bool IsSupersetOf(IEnumerable< T > other, MutationInput origin)
ImmutableHashSet(SortedInt32KeyNode< HashBucket > root, IEqualityComparer< T > equalityComparer, int count)
static bool Contains(T item, MutationInput origin)
ImmutableHashSet< T > SymmetricExcept(IEnumerable< T > other)
ImmutableHashSet< T > Except(IEnumerable< T > other)
static bool SetEquals(IEnumerable< T > other, MutationInput origin)
static MutationResult Remove(T item, MutationInput origin)
ImmutableHashSet< T > WithComparer(IEqualityComparer< T >? equalityComparer)
static bool IsProperSupersetOf(IEnumerable< T > other, MutationInput origin)
ImmutableHashSet(IEqualityComparer< T > equalityComparer)
static SortedInt32KeyNode< HashBucket > UpdateRoot(SortedInt32KeyNode< HashBucket > root, int hashCode, IEqualityComparer< HashBucket > hashBucketEqualityComparer, HashBucket newBucket)
readonly SortedInt32KeyNode< HashBucket > _root
static ImmutableHashSet< TSource > ToImmutableHashSet< TSource >(this IEnumerable< TSource > source, IEqualityComparer< TSource >? equalityComparer)
static bool IsProperSubsetOf(IEnumerable< T > other, MutationInput origin)
static MutationResult Intersect(IEnumerable< T > other, MutationInput origin)
static MutationResult SymmetricExcept(IEnumerable< T > other, MutationInput origin)
readonly IEqualityComparer< T > _equalityComparer
static void Range(bool condition, string? parameterName, string? message=null)
Definition Requires.cs:40
static string CollectionModifiedDuringEnumeration
Definition SR.cs:26
Definition SR.cs:7
void CopyTo(Array array, int index)
SortedInt32KeyNode< HashBucket >.Enumerator _mapEnumerator
Enumerator(SortedInt32KeyNode< HashBucket > root, Builder? builder=null)
bool TryExchange(T value, IEqualityComparer< T > valueComparer, out T existingValue)
HashBucket(T firstElement, ImmutableList< T >.Node additionalElements=null)
bool Contains(T value, IEqualityComparer< T > valueComparer)
bool EqualsByValue(HashBucket other, IEqualityComparer< T > valueComparer)
HashBucket Add(T value, IEqualityComparer< T > valueComparer, out OperationResult result)
HashBucket Remove(T value, IEqualityComparer< T > equalityComparer, out OperationResult result)
readonly IEqualityComparer< HashBucket > _hashBucketEqualityComparer
MutationInput(SortedInt32KeyNode< HashBucket > root, IEqualityComparer< T > equalityComparer, IEqualityComparer< HashBucket > hashBucketEqualityComparer, int count)
MutationResult(SortedInt32KeyNode< HashBucket > root, int count, CountType countType=CountType.Adjustment)
ImmutableHashSet< T > Finalize(ImmutableHashSet< T > priorSet)