Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ UnionWith()

void System.Collections.Generic.SortedSet< T >.UnionWith ( IEnumerable< T > other)
inlineinherited

Implements System.Collections.Generic.ISet< T >.

Definition at line 1342 of file SortedSet.cs.

1343 {
1344 if (other == null)
1345 {
1346 throw new ArgumentNullException("other");
1347 }
1349 TreeSubSet treeSubSet = this as TreeSubSet;
1350 if (treeSubSet != null)
1351 {
1352 VersionCheck();
1353 }
1354 if (sortedSet != null && treeSubSet == null && Count == 0)
1355 {
1357 root = sortedSet2.root;
1358 count = sortedSet2.count;
1359 version++;
1360 }
1361 else if (sortedSet != null && treeSubSet == null && HasEqualComparer(sortedSet) && sortedSet.Count > Count / 2)
1362 {
1363 T[] array = new T[sortedSet.Count + Count];
1364 int num = 0;
1366 Enumerator enumerator2 = sortedSet.GetEnumerator();
1367 bool flag = !enumerator.MoveNext();
1368 bool flag2 = !enumerator2.MoveNext();
1369 while (!flag && !flag2)
1370 {
1371 int num2 = Comparer.Compare(enumerator.Current, enumerator2.Current);
1372 if (num2 < 0)
1373 {
1374 array[num++] = enumerator.Current;
1375 flag = !enumerator.MoveNext();
1376 }
1377 else if (num2 == 0)
1378 {
1379 array[num++] = enumerator2.Current;
1380 flag = !enumerator.MoveNext();
1381 flag2 = !enumerator2.MoveNext();
1382 }
1383 else
1384 {
1385 array[num++] = enumerator2.Current;
1386 flag2 = !enumerator2.MoveNext();
1387 }
1388 }
1389 if (!flag || !flag2)
1390 {
1392 do
1393 {
1394 array[num++] = enumerator3.Current;
1395 }
1396 while (enumerator3.MoveNext());
1397 }
1398 root = null;
1399 root = ConstructRootFromSortedArray(array, 0, num - 1, null);
1400 count = num;
1401 version++;
1402 }
1403 else
1404 {
1406 }
1407 }
static Node ConstructRootFromSortedArray(T[] arr, int startIndex, int endIndex, Node redNode)
void AddAllElements(IEnumerable< T > collection)
Definition SortedSet.cs:805
bool HasEqualComparer(SortedSet< T > other)
virtual void VersionCheck(bool updateCount=false)
Definition SortedSet.cs:894

References System.Collections.Generic.SortedSet< T >.AddAllElements(), System.array, System.Collections.Generic.Comparer< T >.Compare(), System.Collections.Generic.SortedSet< T >.comparer, System.Collections.Generic.SortedSet< T >.ConstructRootFromSortedArray(), System.Collections.Generic.SortedSet< T >.count, System.Collections.Generic.SortedSet< T >.Count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Runtime.Serialization.Dictionary, System.Collections.Generic.SortedSet< T >.GetEnumerator(), System.Collections.Generic.Dictionary< TKey, TValue >.GetEnumerator(), System.Collections.Generic.SortedSet< T >.HasEqualComparer(), System.other, System.Collections.Generic.SortedSet< T >.root, System.Collections.Generic.SortedSet< T >.version, and System.Collections.Generic.SortedSet< T >.VersionCheck().

Referenced by System.Collections.Generic.SortedSet< T >.SymmetricExceptWith().