A game about forced loneliness, made by TACStudios
at master 2281 lines 90 kB view raw
1using System; 2using Unity.Collections.LowLevel.Unsafe; 3 4namespace Unity.Collections.LowLevel.Unsafe 5{ 6 /// <summary> 7 /// Provides extension methods for sets. 8 /// </summary> 9 public unsafe static class HashSetExtensions 10 { 11 /// <summary> 12 /// Removes the values from this set which are also present in another collection. 13 /// </summary> 14 /// <typeparam name="T">The type of values.</typeparam> 15 /// <param name="container">The set to remove values from.</param> 16 /// <param name="other">The collection to compare with.</param> 17 public static void ExceptWith<T>(this ref NativeHashSet<T> container, UnsafeHashSet<T> other) 18 where T : unmanaged, IEquatable<T> 19 { 20 foreach (var item in other) 21 { 22 container.Remove(item); 23 } 24 } 25 26 /// <summary> 27 /// Removes the values from this set which are absent in another collection. 28 /// </summary> 29 /// <typeparam name="T">The type of values.</typeparam> 30 /// <param name="container">The set to remove values from.</param> 31 /// <param name="other">The collection to compare with.</param> 32 public static void IntersectWith<T>(this ref NativeHashSet<T> container, UnsafeHashSet<T> other) 33 where T : unmanaged, IEquatable<T> 34 { 35 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 36 37 foreach (var item in other) 38 { 39 if (container.Contains(item)) 40 { 41 result.Add(item); 42 } 43 } 44 45 container.Clear(); 46 container.UnionWith(result); 47 48 result.Dispose(); 49 } 50 51 /// <summary> 52 /// Adds all values from a collection to this set. 53 /// </summary> 54 /// <typeparam name="T">The type of values.</typeparam> 55 /// <param name="container">The set to add values to.</param> 56 /// <param name="other">The collection to copy values from.</param> 57 public static void UnionWith<T>(this ref NativeHashSet<T> container, UnsafeHashSet<T> other) 58 where T : unmanaged, IEquatable<T> 59 { 60 foreach (var item in other) 61 { 62 container.Add(item); 63 } 64 } 65 /// <summary> 66 /// Removes the values from this set which are also present in another collection. 67 /// </summary> 68 /// <typeparam name="T">The type of values.</typeparam> 69 /// <param name="container">The set to remove values from.</param> 70 /// <param name="other">The collection to compare with.</param> 71 public static void ExceptWith<T>(this ref NativeHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 72 where T : unmanaged, IEquatable<T> 73 { 74 foreach (var item in other) 75 { 76 container.Remove(item); 77 } 78 } 79 80 /// <summary> 81 /// Removes the values from this set which are absent in another collection. 82 /// </summary> 83 /// <typeparam name="T">The type of values.</typeparam> 84 /// <param name="container">The set to remove values from.</param> 85 /// <param name="other">The collection to compare with.</param> 86 public static void IntersectWith<T>(this ref NativeHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 87 where T : unmanaged, IEquatable<T> 88 { 89 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 90 91 foreach (var item in other) 92 { 93 if (container.Contains(item)) 94 { 95 result.Add(item); 96 } 97 } 98 99 container.Clear(); 100 container.UnionWith(result); 101 102 result.Dispose(); 103 } 104 105 /// <summary> 106 /// Adds all values from a collection to this set. 107 /// </summary> 108 /// <typeparam name="T">The type of values.</typeparam> 109 /// <param name="container">The set to add values to.</param> 110 /// <param name="other">The collection to copy values from.</param> 111 public static void UnionWith<T>(this ref NativeHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 112 where T : unmanaged, IEquatable<T> 113 { 114 foreach (var item in other) 115 { 116 container.Add(item); 117 } 118 } 119 /// <summary> 120 /// Removes the values from this set which are also present in another collection. 121 /// </summary> 122 /// <typeparam name="T">The type of values.</typeparam> 123 /// <param name="container">The set to remove values from.</param> 124 /// <param name="other">The collection to compare with.</param> 125 public static void ExceptWith<T>(this ref NativeHashSet<T> container, UnsafeParallelHashSet<T> other) 126 where T : unmanaged, IEquatable<T> 127 { 128 foreach (var item in other) 129 { 130 container.Remove(item); 131 } 132 } 133 134 /// <summary> 135 /// Removes the values from this set which are absent in another collection. 136 /// </summary> 137 /// <typeparam name="T">The type of values.</typeparam> 138 /// <param name="container">The set to remove values from.</param> 139 /// <param name="other">The collection to compare with.</param> 140 public static void IntersectWith<T>(this ref NativeHashSet<T> container, UnsafeParallelHashSet<T> other) 141 where T : unmanaged, IEquatable<T> 142 { 143 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 144 145 foreach (var item in other) 146 { 147 if (container.Contains(item)) 148 { 149 result.Add(item); 150 } 151 } 152 153 container.Clear(); 154 container.UnionWith(result); 155 156 result.Dispose(); 157 } 158 159 /// <summary> 160 /// Adds all values from a collection to this set. 161 /// </summary> 162 /// <typeparam name="T">The type of values.</typeparam> 163 /// <param name="container">The set to add values to.</param> 164 /// <param name="other">The collection to copy values from.</param> 165 public static void UnionWith<T>(this ref NativeHashSet<T> container, UnsafeParallelHashSet<T> other) 166 where T : unmanaged, IEquatable<T> 167 { 168 foreach (var item in other) 169 { 170 container.Add(item); 171 } 172 } 173 /// <summary> 174 /// Removes the values from this set which are also present in another collection. 175 /// </summary> 176 /// <typeparam name="T">The type of values.</typeparam> 177 /// <param name="container">The set to remove values from.</param> 178 /// <param name="other">The collection to compare with.</param> 179 public static void ExceptWith<T>(this ref NativeHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 180 where T : unmanaged, IEquatable<T> 181 { 182 foreach (var item in other) 183 { 184 container.Remove(item); 185 } 186 } 187 188 /// <summary> 189 /// Removes the values from this set which are absent in another collection. 190 /// </summary> 191 /// <typeparam name="T">The type of values.</typeparam> 192 /// <param name="container">The set to remove values from.</param> 193 /// <param name="other">The collection to compare with.</param> 194 public static void IntersectWith<T>(this ref NativeHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 195 where T : unmanaged, IEquatable<T> 196 { 197 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 198 199 foreach (var item in other) 200 { 201 if (container.Contains(item)) 202 { 203 result.Add(item); 204 } 205 } 206 207 container.Clear(); 208 container.UnionWith(result); 209 210 result.Dispose(); 211 } 212 213 /// <summary> 214 /// Adds all values from a collection to this set. 215 /// </summary> 216 /// <typeparam name="T">The type of values.</typeparam> 217 /// <param name="container">The set to add values to.</param> 218 /// <param name="other">The collection to copy values from.</param> 219 public static void UnionWith<T>(this ref NativeHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 220 where T : unmanaged, IEquatable<T> 221 { 222 foreach (var item in other) 223 { 224 container.Add(item); 225 } 226 } 227 /// <summary> 228 /// Removes the values from this set which are also present in another collection. 229 /// </summary> 230 /// <typeparam name="T">The type of values.</typeparam> 231 /// <param name="container">The set to remove values from.</param> 232 /// <param name="other">The collection to compare with.</param> 233 public static void ExceptWith<T>(this ref NativeHashSet<T> container, UnsafeList<T> other) 234 where T : unmanaged, IEquatable<T> 235 { 236 foreach (var item in other) 237 { 238 container.Remove(item); 239 } 240 } 241 242 /// <summary> 243 /// Removes the values from this set which are absent in another collection. 244 /// </summary> 245 /// <typeparam name="T">The type of values.</typeparam> 246 /// <param name="container">The set to remove values from.</param> 247 /// <param name="other">The collection to compare with.</param> 248 public static void IntersectWith<T>(this ref NativeHashSet<T> container, UnsafeList<T> other) 249 where T : unmanaged, IEquatable<T> 250 { 251 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 252 253 foreach (var item in other) 254 { 255 if (container.Contains(item)) 256 { 257 result.Add(item); 258 } 259 } 260 261 container.Clear(); 262 container.UnionWith(result); 263 264 result.Dispose(); 265 } 266 267 /// <summary> 268 /// Adds all values from a collection to this set. 269 /// </summary> 270 /// <typeparam name="T">The type of values.</typeparam> 271 /// <param name="container">The set to add values to.</param> 272 /// <param name="other">The collection to copy values from.</param> 273 public static void UnionWith<T>(this ref NativeHashSet<T> container, UnsafeList<T> other) 274 where T : unmanaged, IEquatable<T> 275 { 276 foreach (var item in other) 277 { 278 container.Add(item); 279 } 280 } 281 /// <summary> 282 /// Removes the values from this set which are also present in another collection. 283 /// </summary> 284 /// <typeparam name="T">The type of values.</typeparam> 285 /// <param name="container">The set to remove values from.</param> 286 /// <param name="other">The collection to compare with.</param> 287 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, UnsafeHashSet<T> other) 288 where T : unmanaged, IEquatable<T> 289 { 290 foreach (var item in other) 291 { 292 container.Remove(item); 293 } 294 } 295 296 /// <summary> 297 /// Removes the values from this set which are absent in another collection. 298 /// </summary> 299 /// <typeparam name="T">The type of values.</typeparam> 300 /// <param name="container">The set to remove values from.</param> 301 /// <param name="other">The collection to compare with.</param> 302 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, UnsafeHashSet<T> other) 303 where T : unmanaged, IEquatable<T> 304 { 305 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 306 307 foreach (var item in other) 308 { 309 if (container.Contains(item)) 310 { 311 result.Add(item); 312 } 313 } 314 315 container.Clear(); 316 container.UnionWith(result); 317 318 result.Dispose(); 319 } 320 321 /// <summary> 322 /// Adds all values from a collection to this set. 323 /// </summary> 324 /// <typeparam name="T">The type of values.</typeparam> 325 /// <param name="container">The set to add values to.</param> 326 /// <param name="other">The collection to copy values from.</param> 327 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, UnsafeHashSet<T> other) 328 where T : unmanaged, IEquatable<T> 329 { 330 foreach (var item in other) 331 { 332 container.Add(item); 333 } 334 } 335 /// <summary> 336 /// Removes the values from this set which are also present in another collection. 337 /// </summary> 338 /// <typeparam name="T">The type of values.</typeparam> 339 /// <param name="container">The set to remove values from.</param> 340 /// <param name="other">The collection to compare with.</param> 341 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 342 where T : unmanaged, IEquatable<T> 343 { 344 foreach (var item in other) 345 { 346 container.Remove(item); 347 } 348 } 349 350 /// <summary> 351 /// Removes the values from this set which are absent in another collection. 352 /// </summary> 353 /// <typeparam name="T">The type of values.</typeparam> 354 /// <param name="container">The set to remove values from.</param> 355 /// <param name="other">The collection to compare with.</param> 356 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 357 where T : unmanaged, IEquatable<T> 358 { 359 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 360 361 foreach (var item in other) 362 { 363 if (container.Contains(item)) 364 { 365 result.Add(item); 366 } 367 } 368 369 container.Clear(); 370 container.UnionWith(result); 371 372 result.Dispose(); 373 } 374 375 /// <summary> 376 /// Adds all values from a collection to this set. 377 /// </summary> 378 /// <typeparam name="T">The type of values.</typeparam> 379 /// <param name="container">The set to add values to.</param> 380 /// <param name="other">The collection to copy values from.</param> 381 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 382 where T : unmanaged, IEquatable<T> 383 { 384 foreach (var item in other) 385 { 386 container.Add(item); 387 } 388 } 389 /// <summary> 390 /// Removes the values from this set which are also present in another collection. 391 /// </summary> 392 /// <typeparam name="T">The type of values.</typeparam> 393 /// <param name="container">The set to remove values from.</param> 394 /// <param name="other">The collection to compare with.</param> 395 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, UnsafeParallelHashSet<T> other) 396 where T : unmanaged, IEquatable<T> 397 { 398 foreach (var item in other) 399 { 400 container.Remove(item); 401 } 402 } 403 404 /// <summary> 405 /// Removes the values from this set which are absent in another collection. 406 /// </summary> 407 /// <typeparam name="T">The type of values.</typeparam> 408 /// <param name="container">The set to remove values from.</param> 409 /// <param name="other">The collection to compare with.</param> 410 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, UnsafeParallelHashSet<T> other) 411 where T : unmanaged, IEquatable<T> 412 { 413 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 414 415 foreach (var item in other) 416 { 417 if (container.Contains(item)) 418 { 419 result.Add(item); 420 } 421 } 422 423 container.Clear(); 424 container.UnionWith(result); 425 426 result.Dispose(); 427 } 428 429 /// <summary> 430 /// Adds all values from a collection to this set. 431 /// </summary> 432 /// <typeparam name="T">The type of values.</typeparam> 433 /// <param name="container">The set to add values to.</param> 434 /// <param name="other">The collection to copy values from.</param> 435 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, UnsafeParallelHashSet<T> other) 436 where T : unmanaged, IEquatable<T> 437 { 438 foreach (var item in other) 439 { 440 container.Add(item); 441 } 442 } 443 /// <summary> 444 /// Removes the values from this set which are also present in another collection. 445 /// </summary> 446 /// <typeparam name="T">The type of values.</typeparam> 447 /// <param name="container">The set to remove values from.</param> 448 /// <param name="other">The collection to compare with.</param> 449 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 450 where T : unmanaged, IEquatable<T> 451 { 452 foreach (var item in other) 453 { 454 container.Remove(item); 455 } 456 } 457 458 /// <summary> 459 /// Removes the values from this set which are absent in another collection. 460 /// </summary> 461 /// <typeparam name="T">The type of values.</typeparam> 462 /// <param name="container">The set to remove values from.</param> 463 /// <param name="other">The collection to compare with.</param> 464 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 465 where T : unmanaged, IEquatable<T> 466 { 467 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 468 469 foreach (var item in other) 470 { 471 if (container.Contains(item)) 472 { 473 result.Add(item); 474 } 475 } 476 477 container.Clear(); 478 container.UnionWith(result); 479 480 result.Dispose(); 481 } 482 483 /// <summary> 484 /// Adds all values from a collection to this set. 485 /// </summary> 486 /// <typeparam name="T">The type of values.</typeparam> 487 /// <param name="container">The set to add values to.</param> 488 /// <param name="other">The collection to copy values from.</param> 489 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 490 where T : unmanaged, IEquatable<T> 491 { 492 foreach (var item in other) 493 { 494 container.Add(item); 495 } 496 } 497 /// <summary> 498 /// Removes the values from this set which are also present in another collection. 499 /// </summary> 500 /// <typeparam name="T">The type of values.</typeparam> 501 /// <param name="container">The set to remove values from.</param> 502 /// <param name="other">The collection to compare with.</param> 503 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, UnsafeList<T> other) 504 where T : unmanaged, IEquatable<T> 505 { 506 foreach (var item in other) 507 { 508 container.Remove(item); 509 } 510 } 511 512 /// <summary> 513 /// Removes the values from this set which are absent in another collection. 514 /// </summary> 515 /// <typeparam name="T">The type of values.</typeparam> 516 /// <param name="container">The set to remove values from.</param> 517 /// <param name="other">The collection to compare with.</param> 518 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, UnsafeList<T> other) 519 where T : unmanaged, IEquatable<T> 520 { 521 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 522 523 foreach (var item in other) 524 { 525 if (container.Contains(item)) 526 { 527 result.Add(item); 528 } 529 } 530 531 container.Clear(); 532 container.UnionWith(result); 533 534 result.Dispose(); 535 } 536 537 /// <summary> 538 /// Adds all values from a collection to this set. 539 /// </summary> 540 /// <typeparam name="T">The type of values.</typeparam> 541 /// <param name="container">The set to add values to.</param> 542 /// <param name="other">The collection to copy values from.</param> 543 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, UnsafeList<T> other) 544 where T : unmanaged, IEquatable<T> 545 { 546 foreach (var item in other) 547 { 548 container.Add(item); 549 } 550 } 551 552 /// <summary> 553 /// Removes the values from this set which are also present in another collection. 554 /// </summary> 555 /// <typeparam name="T">The type of values.</typeparam> 556 /// <param name="container">The set to remove values from.</param> 557 /// <param name="other">The collection to compare with.</param> 558 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, FixedList128Bytes<T> other) 559 where T : unmanaged, IEquatable<T> 560 { 561 foreach (var item in other) 562 { 563 container.Remove(item); 564 } 565 } 566 567 /// <summary> 568 /// Removes the values from this set which are absent in another collection. 569 /// </summary> 570 /// <typeparam name="T">The type of values.</typeparam> 571 /// <param name="container">The set to remove values from.</param> 572 /// <param name="other">The collection to compare with.</param> 573 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, FixedList128Bytes<T> other) 574 where T : unmanaged, IEquatable<T> 575 { 576 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 577 578 foreach (var item in other) 579 { 580 if (container.Contains(item)) 581 { 582 result.Add(item); 583 } 584 } 585 586 container.Clear(); 587 container.UnionWith(result); 588 589 result.Dispose(); 590 } 591 592 /// <summary> 593 /// Adds all values from a collection to this set. 594 /// </summary> 595 /// <typeparam name="T">The type of values.</typeparam> 596 /// <param name="container">The set to add values to.</param> 597 /// <param name="other">The collection to copy values from.</param> 598 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, FixedList128Bytes<T> other) 599 where T : unmanaged, IEquatable<T> 600 { 601 foreach (var item in other) 602 { 603 container.Add(item); 604 } 605 } 606 /// <summary> 607 /// Removes the values from this set which are also present in another collection. 608 /// </summary> 609 /// <typeparam name="T">The type of values.</typeparam> 610 /// <param name="container">The set to remove values from.</param> 611 /// <param name="other">The collection to compare with.</param> 612 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, FixedList32Bytes<T> other) 613 where T : unmanaged, IEquatable<T> 614 { 615 foreach (var item in other) 616 { 617 container.Remove(item); 618 } 619 } 620 621 /// <summary> 622 /// Removes the values from this set which are absent in another collection. 623 /// </summary> 624 /// <typeparam name="T">The type of values.</typeparam> 625 /// <param name="container">The set to remove values from.</param> 626 /// <param name="other">The collection to compare with.</param> 627 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, FixedList32Bytes<T> other) 628 where T : unmanaged, IEquatable<T> 629 { 630 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 631 632 foreach (var item in other) 633 { 634 if (container.Contains(item)) 635 { 636 result.Add(item); 637 } 638 } 639 640 container.Clear(); 641 container.UnionWith(result); 642 643 result.Dispose(); 644 } 645 646 /// <summary> 647 /// Adds all values from a collection to this set. 648 /// </summary> 649 /// <typeparam name="T">The type of values.</typeparam> 650 /// <param name="container">The set to add values to.</param> 651 /// <param name="other">The collection to copy values from.</param> 652 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, FixedList32Bytes<T> other) 653 where T : unmanaged, IEquatable<T> 654 { 655 foreach (var item in other) 656 { 657 container.Add(item); 658 } 659 } 660 /// <summary> 661 /// Removes the values from this set which are also present in another collection. 662 /// </summary> 663 /// <typeparam name="T">The type of values.</typeparam> 664 /// <param name="container">The set to remove values from.</param> 665 /// <param name="other">The collection to compare with.</param> 666 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, FixedList4096Bytes<T> other) 667 where T : unmanaged, IEquatable<T> 668 { 669 foreach (var item in other) 670 { 671 container.Remove(item); 672 } 673 } 674 675 /// <summary> 676 /// Removes the values from this set which are absent in another collection. 677 /// </summary> 678 /// <typeparam name="T">The type of values.</typeparam> 679 /// <param name="container">The set to remove values from.</param> 680 /// <param name="other">The collection to compare with.</param> 681 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, FixedList4096Bytes<T> other) 682 where T : unmanaged, IEquatable<T> 683 { 684 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 685 686 foreach (var item in other) 687 { 688 if (container.Contains(item)) 689 { 690 result.Add(item); 691 } 692 } 693 694 container.Clear(); 695 container.UnionWith(result); 696 697 result.Dispose(); 698 } 699 700 /// <summary> 701 /// Adds all values from a collection to this set. 702 /// </summary> 703 /// <typeparam name="T">The type of values.</typeparam> 704 /// <param name="container">The set to add values to.</param> 705 /// <param name="other">The collection to copy values from.</param> 706 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, FixedList4096Bytes<T> other) 707 where T : unmanaged, IEquatable<T> 708 { 709 foreach (var item in other) 710 { 711 container.Add(item); 712 } 713 } 714 /// <summary> 715 /// Removes the values from this set which are also present in another collection. 716 /// </summary> 717 /// <typeparam name="T">The type of values.</typeparam> 718 /// <param name="container">The set to remove values from.</param> 719 /// <param name="other">The collection to compare with.</param> 720 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, FixedList512Bytes<T> other) 721 where T : unmanaged, IEquatable<T> 722 { 723 foreach (var item in other) 724 { 725 container.Remove(item); 726 } 727 } 728 729 /// <summary> 730 /// Removes the values from this set which are absent in another collection. 731 /// </summary> 732 /// <typeparam name="T">The type of values.</typeparam> 733 /// <param name="container">The set to remove values from.</param> 734 /// <param name="other">The collection to compare with.</param> 735 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, FixedList512Bytes<T> other) 736 where T : unmanaged, IEquatable<T> 737 { 738 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 739 740 foreach (var item in other) 741 { 742 if (container.Contains(item)) 743 { 744 result.Add(item); 745 } 746 } 747 748 container.Clear(); 749 container.UnionWith(result); 750 751 result.Dispose(); 752 } 753 754 /// <summary> 755 /// Adds all values from a collection to this set. 756 /// </summary> 757 /// <typeparam name="T">The type of values.</typeparam> 758 /// <param name="container">The set to add values to.</param> 759 /// <param name="other">The collection to copy values from.</param> 760 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, FixedList512Bytes<T> other) 761 where T : unmanaged, IEquatable<T> 762 { 763 foreach (var item in other) 764 { 765 container.Add(item); 766 } 767 } 768 /// <summary> 769 /// Removes the values from this set which are also present in another collection. 770 /// </summary> 771 /// <typeparam name="T">The type of values.</typeparam> 772 /// <param name="container">The set to remove values from.</param> 773 /// <param name="other">The collection to compare with.</param> 774 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, FixedList64Bytes<T> other) 775 where T : unmanaged, IEquatable<T> 776 { 777 foreach (var item in other) 778 { 779 container.Remove(item); 780 } 781 } 782 783 /// <summary> 784 /// Removes the values from this set which are absent in another collection. 785 /// </summary> 786 /// <typeparam name="T">The type of values.</typeparam> 787 /// <param name="container">The set to remove values from.</param> 788 /// <param name="other">The collection to compare with.</param> 789 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, FixedList64Bytes<T> other) 790 where T : unmanaged, IEquatable<T> 791 { 792 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 793 794 foreach (var item in other) 795 { 796 if (container.Contains(item)) 797 { 798 result.Add(item); 799 } 800 } 801 802 container.Clear(); 803 container.UnionWith(result); 804 805 result.Dispose(); 806 } 807 808 /// <summary> 809 /// Adds all values from a collection to this set. 810 /// </summary> 811 /// <typeparam name="T">The type of values.</typeparam> 812 /// <param name="container">The set to add values to.</param> 813 /// <param name="other">The collection to copy values from.</param> 814 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, FixedList64Bytes<T> other) 815 where T : unmanaged, IEquatable<T> 816 { 817 foreach (var item in other) 818 { 819 container.Add(item); 820 } 821 } 822 /// <summary> 823 /// Removes the values from this set which are also present in another collection. 824 /// </summary> 825 /// <typeparam name="T">The type of values.</typeparam> 826 /// <param name="container">The set to remove values from.</param> 827 /// <param name="other">The collection to compare with.</param> 828 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, NativeArray<T> other) 829 where T : unmanaged, IEquatable<T> 830 { 831 foreach (var item in other) 832 { 833 container.Remove(item); 834 } 835 } 836 837 /// <summary> 838 /// Removes the values from this set which are absent in another collection. 839 /// </summary> 840 /// <typeparam name="T">The type of values.</typeparam> 841 /// <param name="container">The set to remove values from.</param> 842 /// <param name="other">The collection to compare with.</param> 843 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, NativeArray<T> other) 844 where T : unmanaged, IEquatable<T> 845 { 846 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 847 848 foreach (var item in other) 849 { 850 if (container.Contains(item)) 851 { 852 result.Add(item); 853 } 854 } 855 856 container.Clear(); 857 container.UnionWith(result); 858 859 result.Dispose(); 860 } 861 862 /// <summary> 863 /// Adds all values from a collection to this set. 864 /// </summary> 865 /// <typeparam name="T">The type of values.</typeparam> 866 /// <param name="container">The set to add values to.</param> 867 /// <param name="other">The collection to copy values from.</param> 868 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, NativeArray<T> other) 869 where T : unmanaged, IEquatable<T> 870 { 871 foreach (var item in other) 872 { 873 container.Add(item); 874 } 875 } 876 /// <summary> 877 /// Removes the values from this set which are also present in another collection. 878 /// </summary> 879 /// <typeparam name="T">The type of values.</typeparam> 880 /// <param name="container">The set to remove values from.</param> 881 /// <param name="other">The collection to compare with.</param> 882 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, NativeHashSet<T> other) 883 where T : unmanaged, IEquatable<T> 884 { 885 foreach (var item in other) 886 { 887 container.Remove(item); 888 } 889 } 890 891 /// <summary> 892 /// Removes the values from this set which are absent in another collection. 893 /// </summary> 894 /// <typeparam name="T">The type of values.</typeparam> 895 /// <param name="container">The set to remove values from.</param> 896 /// <param name="other">The collection to compare with.</param> 897 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, NativeHashSet<T> other) 898 where T : unmanaged, IEquatable<T> 899 { 900 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 901 902 foreach (var item in other) 903 { 904 if (container.Contains(item)) 905 { 906 result.Add(item); 907 } 908 } 909 910 container.Clear(); 911 container.UnionWith(result); 912 913 result.Dispose(); 914 } 915 916 /// <summary> 917 /// Adds all values from a collection to this set. 918 /// </summary> 919 /// <typeparam name="T">The type of values.</typeparam> 920 /// <param name="container">The set to add values to.</param> 921 /// <param name="other">The collection to copy values from.</param> 922 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, NativeHashSet<T> other) 923 where T : unmanaged, IEquatable<T> 924 { 925 foreach (var item in other) 926 { 927 container.Add(item); 928 } 929 } 930 /// <summary> 931 /// Removes the values from this set which are also present in another collection. 932 /// </summary> 933 /// <typeparam name="T">The type of values.</typeparam> 934 /// <param name="container">The set to remove values from.</param> 935 /// <param name="other">The collection to compare with.</param> 936 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, NativeHashSet<T>.ReadOnly other) 937 where T : unmanaged, IEquatable<T> 938 { 939 foreach (var item in other) 940 { 941 container.Remove(item); 942 } 943 } 944 945 /// <summary> 946 /// Removes the values from this set which are absent in another collection. 947 /// </summary> 948 /// <typeparam name="T">The type of values.</typeparam> 949 /// <param name="container">The set to remove values from.</param> 950 /// <param name="other">The collection to compare with.</param> 951 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, NativeHashSet<T>.ReadOnly other) 952 where T : unmanaged, IEquatable<T> 953 { 954 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 955 956 foreach (var item in other) 957 { 958 if (container.Contains(item)) 959 { 960 result.Add(item); 961 } 962 } 963 964 container.Clear(); 965 container.UnionWith(result); 966 967 result.Dispose(); 968 } 969 970 /// <summary> 971 /// Adds all values from a collection to this set. 972 /// </summary> 973 /// <typeparam name="T">The type of values.</typeparam> 974 /// <param name="container">The set to add values to.</param> 975 /// <param name="other">The collection to copy values from.</param> 976 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, NativeHashSet<T>.ReadOnly other) 977 where T : unmanaged, IEquatable<T> 978 { 979 foreach (var item in other) 980 { 981 container.Add(item); 982 } 983 } 984 /// <summary> 985 /// Removes the values from this set which are also present in another collection. 986 /// </summary> 987 /// <typeparam name="T">The type of values.</typeparam> 988 /// <param name="container">The set to remove values from.</param> 989 /// <param name="other">The collection to compare with.</param> 990 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, UnsafeHashSet<T> other) 991 where T : unmanaged, IEquatable<T> 992 { 993 foreach (var item in other) 994 { 995 container.Remove(item); 996 } 997 } 998 999 /// <summary> 1000 /// Removes the values from this set which are absent in another collection. 1001 /// </summary> 1002 /// <typeparam name="T">The type of values.</typeparam> 1003 /// <param name="container">The set to remove values from.</param> 1004 /// <param name="other">The collection to compare with.</param> 1005 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, UnsafeHashSet<T> other) 1006 where T : unmanaged, IEquatable<T> 1007 { 1008 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 1009 1010 foreach (var item in other) 1011 { 1012 if (container.Contains(item)) 1013 { 1014 result.Add(item); 1015 } 1016 } 1017 1018 container.Clear(); 1019 container.UnionWith(result); 1020 1021 result.Dispose(); 1022 } 1023 1024 /// <summary> 1025 /// Adds all values from a collection to this set. 1026 /// </summary> 1027 /// <typeparam name="T">The type of values.</typeparam> 1028 /// <param name="container">The set to add values to.</param> 1029 /// <param name="other">The collection to copy values from.</param> 1030 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, UnsafeHashSet<T> other) 1031 where T : unmanaged, IEquatable<T> 1032 { 1033 foreach (var item in other) 1034 { 1035 container.Add(item); 1036 } 1037 } 1038 /// <summary> 1039 /// Removes the values from this set which are also present in another collection. 1040 /// </summary> 1041 /// <typeparam name="T">The type of values.</typeparam> 1042 /// <param name="container">The set to remove values from.</param> 1043 /// <param name="other">The collection to compare with.</param> 1044 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 1045 where T : unmanaged, IEquatable<T> 1046 { 1047 foreach (var item in other) 1048 { 1049 container.Remove(item); 1050 } 1051 } 1052 1053 /// <summary> 1054 /// Removes the values from this set which are absent in another collection. 1055 /// </summary> 1056 /// <typeparam name="T">The type of values.</typeparam> 1057 /// <param name="container">The set to remove values from.</param> 1058 /// <param name="other">The collection to compare with.</param> 1059 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 1060 where T : unmanaged, IEquatable<T> 1061 { 1062 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 1063 1064 foreach (var item in other) 1065 { 1066 if (container.Contains(item)) 1067 { 1068 result.Add(item); 1069 } 1070 } 1071 1072 container.Clear(); 1073 container.UnionWith(result); 1074 1075 result.Dispose(); 1076 } 1077 1078 /// <summary> 1079 /// Adds all values from a collection to this set. 1080 /// </summary> 1081 /// <typeparam name="T">The type of values.</typeparam> 1082 /// <param name="container">The set to add values to.</param> 1083 /// <param name="other">The collection to copy values from.</param> 1084 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 1085 where T : unmanaged, IEquatable<T> 1086 { 1087 foreach (var item in other) 1088 { 1089 container.Add(item); 1090 } 1091 } 1092 /// <summary> 1093 /// Removes the values from this set which are also present in another collection. 1094 /// </summary> 1095 /// <typeparam name="T">The type of values.</typeparam> 1096 /// <param name="container">The set to remove values from.</param> 1097 /// <param name="other">The collection to compare with.</param> 1098 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, NativeParallelHashSet<T> other) 1099 where T : unmanaged, IEquatable<T> 1100 { 1101 foreach (var item in other) 1102 { 1103 container.Remove(item); 1104 } 1105 } 1106 1107 /// <summary> 1108 /// Removes the values from this set which are absent in another collection. 1109 /// </summary> 1110 /// <typeparam name="T">The type of values.</typeparam> 1111 /// <param name="container">The set to remove values from.</param> 1112 /// <param name="other">The collection to compare with.</param> 1113 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, NativeParallelHashSet<T> other) 1114 where T : unmanaged, IEquatable<T> 1115 { 1116 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 1117 1118 foreach (var item in other) 1119 { 1120 if (container.Contains(item)) 1121 { 1122 result.Add(item); 1123 } 1124 } 1125 1126 container.Clear(); 1127 container.UnionWith(result); 1128 1129 result.Dispose(); 1130 } 1131 1132 /// <summary> 1133 /// Adds all values from a collection to this set. 1134 /// </summary> 1135 /// <typeparam name="T">The type of values.</typeparam> 1136 /// <param name="container">The set to add values to.</param> 1137 /// <param name="other">The collection to copy values from.</param> 1138 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, NativeParallelHashSet<T> other) 1139 where T : unmanaged, IEquatable<T> 1140 { 1141 foreach (var item in other) 1142 { 1143 container.Add(item); 1144 } 1145 } 1146 /// <summary> 1147 /// Removes the values from this set which are also present in another collection. 1148 /// </summary> 1149 /// <typeparam name="T">The type of values.</typeparam> 1150 /// <param name="container">The set to remove values from.</param> 1151 /// <param name="other">The collection to compare with.</param> 1152 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 1153 where T : unmanaged, IEquatable<T> 1154 { 1155 foreach (var item in other) 1156 { 1157 container.Remove(item); 1158 } 1159 } 1160 1161 /// <summary> 1162 /// Removes the values from this set which are absent in another collection. 1163 /// </summary> 1164 /// <typeparam name="T">The type of values.</typeparam> 1165 /// <param name="container">The set to remove values from.</param> 1166 /// <param name="other">The collection to compare with.</param> 1167 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 1168 where T : unmanaged, IEquatable<T> 1169 { 1170 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 1171 1172 foreach (var item in other) 1173 { 1174 if (container.Contains(item)) 1175 { 1176 result.Add(item); 1177 } 1178 } 1179 1180 container.Clear(); 1181 container.UnionWith(result); 1182 1183 result.Dispose(); 1184 } 1185 1186 /// <summary> 1187 /// Adds all values from a collection to this set. 1188 /// </summary> 1189 /// <typeparam name="T">The type of values.</typeparam> 1190 /// <param name="container">The set to add values to.</param> 1191 /// <param name="other">The collection to copy values from.</param> 1192 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 1193 where T : unmanaged, IEquatable<T> 1194 { 1195 foreach (var item in other) 1196 { 1197 container.Add(item); 1198 } 1199 } 1200 /// <summary> 1201 /// Removes the values from this set which are also present in another collection. 1202 /// </summary> 1203 /// <typeparam name="T">The type of values.</typeparam> 1204 /// <param name="container">The set to remove values from.</param> 1205 /// <param name="other">The collection to compare with.</param> 1206 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, UnsafeParallelHashSet<T> other) 1207 where T : unmanaged, IEquatable<T> 1208 { 1209 foreach (var item in other) 1210 { 1211 container.Remove(item); 1212 } 1213 } 1214 1215 /// <summary> 1216 /// Removes the values from this set which are absent in another collection. 1217 /// </summary> 1218 /// <typeparam name="T">The type of values.</typeparam> 1219 /// <param name="container">The set to remove values from.</param> 1220 /// <param name="other">The collection to compare with.</param> 1221 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, UnsafeParallelHashSet<T> other) 1222 where T : unmanaged, IEquatable<T> 1223 { 1224 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 1225 1226 foreach (var item in other) 1227 { 1228 if (container.Contains(item)) 1229 { 1230 result.Add(item); 1231 } 1232 } 1233 1234 container.Clear(); 1235 container.UnionWith(result); 1236 1237 result.Dispose(); 1238 } 1239 1240 /// <summary> 1241 /// Adds all values from a collection to this set. 1242 /// </summary> 1243 /// <typeparam name="T">The type of values.</typeparam> 1244 /// <param name="container">The set to add values to.</param> 1245 /// <param name="other">The collection to copy values from.</param> 1246 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, UnsafeParallelHashSet<T> other) 1247 where T : unmanaged, IEquatable<T> 1248 { 1249 foreach (var item in other) 1250 { 1251 container.Add(item); 1252 } 1253 } 1254 /// <summary> 1255 /// Removes the values from this set which are also present in another collection. 1256 /// </summary> 1257 /// <typeparam name="T">The type of values.</typeparam> 1258 /// <param name="container">The set to remove values from.</param> 1259 /// <param name="other">The collection to compare with.</param> 1260 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 1261 where T : unmanaged, IEquatable<T> 1262 { 1263 foreach (var item in other) 1264 { 1265 container.Remove(item); 1266 } 1267 } 1268 1269 /// <summary> 1270 /// Removes the values from this set which are absent in another collection. 1271 /// </summary> 1272 /// <typeparam name="T">The type of values.</typeparam> 1273 /// <param name="container">The set to remove values from.</param> 1274 /// <param name="other">The collection to compare with.</param> 1275 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 1276 where T : unmanaged, IEquatable<T> 1277 { 1278 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 1279 1280 foreach (var item in other) 1281 { 1282 if (container.Contains(item)) 1283 { 1284 result.Add(item); 1285 } 1286 } 1287 1288 container.Clear(); 1289 container.UnionWith(result); 1290 1291 result.Dispose(); 1292 } 1293 1294 /// <summary> 1295 /// Adds all values from a collection to this set. 1296 /// </summary> 1297 /// <typeparam name="T">The type of values.</typeparam> 1298 /// <param name="container">The set to add values to.</param> 1299 /// <param name="other">The collection to copy values from.</param> 1300 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 1301 where T : unmanaged, IEquatable<T> 1302 { 1303 foreach (var item in other) 1304 { 1305 container.Add(item); 1306 } 1307 } 1308 /// <summary> 1309 /// Removes the values from this set which are also present in another collection. 1310 /// </summary> 1311 /// <typeparam name="T">The type of values.</typeparam> 1312 /// <param name="container">The set to remove values from.</param> 1313 /// <param name="other">The collection to compare with.</param> 1314 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, NativeList<T> other) 1315 where T : unmanaged, IEquatable<T> 1316 { 1317 foreach (var item in other) 1318 { 1319 container.Remove(item); 1320 } 1321 } 1322 1323 /// <summary> 1324 /// Removes the values from this set which are absent in another collection. 1325 /// </summary> 1326 /// <typeparam name="T">The type of values.</typeparam> 1327 /// <param name="container">The set to remove values from.</param> 1328 /// <param name="other">The collection to compare with.</param> 1329 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, NativeList<T> other) 1330 where T : unmanaged, IEquatable<T> 1331 { 1332 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 1333 1334 foreach (var item in other) 1335 { 1336 if (container.Contains(item)) 1337 { 1338 result.Add(item); 1339 } 1340 } 1341 1342 container.Clear(); 1343 container.UnionWith(result); 1344 1345 result.Dispose(); 1346 } 1347 1348 /// <summary> 1349 /// Adds all values from a collection to this set. 1350 /// </summary> 1351 /// <typeparam name="T">The type of values.</typeparam> 1352 /// <param name="container">The set to add values to.</param> 1353 /// <param name="other">The collection to copy values from.</param> 1354 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, NativeList<T> other) 1355 where T : unmanaged, IEquatable<T> 1356 { 1357 foreach (var item in other) 1358 { 1359 container.Add(item); 1360 } 1361 } 1362 /// <summary> 1363 /// Removes the values from this set which are also present in another collection. 1364 /// </summary> 1365 /// <typeparam name="T">The type of values.</typeparam> 1366 /// <param name="container">The set to remove values from.</param> 1367 /// <param name="other">The collection to compare with.</param> 1368 public static void ExceptWith<T>(this ref UnsafeHashSet<T> container, UnsafeList<T> other) 1369 where T : unmanaged, IEquatable<T> 1370 { 1371 foreach (var item in other) 1372 { 1373 container.Remove(item); 1374 } 1375 } 1376 1377 /// <summary> 1378 /// Removes the values from this set which are absent in another collection. 1379 /// </summary> 1380 /// <typeparam name="T">The type of values.</typeparam> 1381 /// <param name="container">The set to remove values from.</param> 1382 /// <param name="other">The collection to compare with.</param> 1383 public static void IntersectWith<T>(this ref UnsafeHashSet<T> container, UnsafeList<T> other) 1384 where T : unmanaged, IEquatable<T> 1385 { 1386 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 1387 1388 foreach (var item in other) 1389 { 1390 if (container.Contains(item)) 1391 { 1392 result.Add(item); 1393 } 1394 } 1395 1396 container.Clear(); 1397 container.UnionWith(result); 1398 1399 result.Dispose(); 1400 } 1401 1402 /// <summary> 1403 /// Adds all values from a collection to this set. 1404 /// </summary> 1405 /// <typeparam name="T">The type of values.</typeparam> 1406 /// <param name="container">The set to add values to.</param> 1407 /// <param name="other">The collection to copy values from.</param> 1408 public static void UnionWith<T>(this ref UnsafeHashSet<T> container, UnsafeList<T> other) 1409 where T : unmanaged, IEquatable<T> 1410 { 1411 foreach (var item in other) 1412 { 1413 container.Add(item); 1414 } 1415 } 1416 /// <summary> 1417 /// Removes the values from this set which are also present in another collection. 1418 /// </summary> 1419 /// <typeparam name="T">The type of values.</typeparam> 1420 /// <param name="container">The set to remove values from.</param> 1421 /// <param name="other">The collection to compare with.</param> 1422 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList128Bytes<T> other) 1423 where T : unmanaged, IEquatable<T> 1424 { 1425 foreach (var item in other) 1426 { 1427 container.Remove(item); 1428 } 1429 } 1430 1431 /// <summary> 1432 /// Removes the values from this set which are absent in another collection. 1433 /// </summary> 1434 /// <typeparam name="T">The type of values.</typeparam> 1435 /// <param name="container">The set to remove values from.</param> 1436 /// <param name="other">The collection to compare with.</param> 1437 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList128Bytes<T> other) 1438 where T : unmanaged, IEquatable<T> 1439 { 1440 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1441 1442 foreach (var item in other) 1443 { 1444 if (container.Contains(item)) 1445 { 1446 result.Add(item); 1447 } 1448 } 1449 1450 container.Clear(); 1451 container.UnionWith(result); 1452 1453 result.Dispose(); 1454 } 1455 1456 /// <summary> 1457 /// Adds all values from a collection to this set. 1458 /// </summary> 1459 /// <typeparam name="T">The type of values.</typeparam> 1460 /// <param name="container">The set to add values to.</param> 1461 /// <param name="other">The collection to copy values from.</param> 1462 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList128Bytes<T> other) 1463 where T : unmanaged, IEquatable<T> 1464 { 1465 foreach (var item in other) 1466 { 1467 container.Add(item); 1468 } 1469 } 1470 /// <summary> 1471 /// Removes the values from this set which are also present in another collection. 1472 /// </summary> 1473 /// <typeparam name="T">The type of values.</typeparam> 1474 /// <param name="container">The set to remove values from.</param> 1475 /// <param name="other">The collection to compare with.</param> 1476 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList32Bytes<T> other) 1477 where T : unmanaged, IEquatable<T> 1478 { 1479 foreach (var item in other) 1480 { 1481 container.Remove(item); 1482 } 1483 } 1484 1485 /// <summary> 1486 /// Removes the values from this set which are absent in another collection. 1487 /// </summary> 1488 /// <typeparam name="T">The type of values.</typeparam> 1489 /// <param name="container">The set to remove values from.</param> 1490 /// <param name="other">The collection to compare with.</param> 1491 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList32Bytes<T> other) 1492 where T : unmanaged, IEquatable<T> 1493 { 1494 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1495 1496 foreach (var item in other) 1497 { 1498 if (container.Contains(item)) 1499 { 1500 result.Add(item); 1501 } 1502 } 1503 1504 container.Clear(); 1505 container.UnionWith(result); 1506 1507 result.Dispose(); 1508 } 1509 1510 /// <summary> 1511 /// Adds all values from a collection to this set. 1512 /// </summary> 1513 /// <typeparam name="T">The type of values.</typeparam> 1514 /// <param name="container">The set to add values to.</param> 1515 /// <param name="other">The collection to copy values from.</param> 1516 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList32Bytes<T> other) 1517 where T : unmanaged, IEquatable<T> 1518 { 1519 foreach (var item in other) 1520 { 1521 container.Add(item); 1522 } 1523 } 1524 /// <summary> 1525 /// Removes the values from this set which are also present in another collection. 1526 /// </summary> 1527 /// <typeparam name="T">The type of values.</typeparam> 1528 /// <param name="container">The set to remove values from.</param> 1529 /// <param name="other">The collection to compare with.</param> 1530 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList4096Bytes<T> other) 1531 where T : unmanaged, IEquatable<T> 1532 { 1533 foreach (var item in other) 1534 { 1535 container.Remove(item); 1536 } 1537 } 1538 1539 /// <summary> 1540 /// Removes the values from this set which are absent in another collection. 1541 /// </summary> 1542 /// <typeparam name="T">The type of values.</typeparam> 1543 /// <param name="container">The set to remove values from.</param> 1544 /// <param name="other">The collection to compare with.</param> 1545 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList4096Bytes<T> other) 1546 where T : unmanaged, IEquatable<T> 1547 { 1548 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1549 1550 foreach (var item in other) 1551 { 1552 if (container.Contains(item)) 1553 { 1554 result.Add(item); 1555 } 1556 } 1557 1558 container.Clear(); 1559 container.UnionWith(result); 1560 1561 result.Dispose(); 1562 } 1563 1564 /// <summary> 1565 /// Adds all values from a collection to this set. 1566 /// </summary> 1567 /// <typeparam name="T">The type of values.</typeparam> 1568 /// <param name="container">The set to add values to.</param> 1569 /// <param name="other">The collection to copy values from.</param> 1570 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList4096Bytes<T> other) 1571 where T : unmanaged, IEquatable<T> 1572 { 1573 foreach (var item in other) 1574 { 1575 container.Add(item); 1576 } 1577 } 1578 /// <summary> 1579 /// Removes the values from this set which are also present in another collection. 1580 /// </summary> 1581 /// <typeparam name="T">The type of values.</typeparam> 1582 /// <param name="container">The set to remove values from.</param> 1583 /// <param name="other">The collection to compare with.</param> 1584 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList512Bytes<T> other) 1585 where T : unmanaged, IEquatable<T> 1586 { 1587 foreach (var item in other) 1588 { 1589 container.Remove(item); 1590 } 1591 } 1592 1593 /// <summary> 1594 /// Removes the values from this set which are absent in another collection. 1595 /// </summary> 1596 /// <typeparam name="T">The type of values.</typeparam> 1597 /// <param name="container">The set to remove values from.</param> 1598 /// <param name="other">The collection to compare with.</param> 1599 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList512Bytes<T> other) 1600 where T : unmanaged, IEquatable<T> 1601 { 1602 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1603 1604 foreach (var item in other) 1605 { 1606 if (container.Contains(item)) 1607 { 1608 result.Add(item); 1609 } 1610 } 1611 1612 container.Clear(); 1613 container.UnionWith(result); 1614 1615 result.Dispose(); 1616 } 1617 1618 /// <summary> 1619 /// Adds all values from a collection to this set. 1620 /// </summary> 1621 /// <typeparam name="T">The type of values.</typeparam> 1622 /// <param name="container">The set to add values to.</param> 1623 /// <param name="other">The collection to copy values from.</param> 1624 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList512Bytes<T> other) 1625 where T : unmanaged, IEquatable<T> 1626 { 1627 foreach (var item in other) 1628 { 1629 container.Add(item); 1630 } 1631 } 1632 /// <summary> 1633 /// Removes the values from this set which are also present in another collection. 1634 /// </summary> 1635 /// <typeparam name="T">The type of values.</typeparam> 1636 /// <param name="container">The set to remove values from.</param> 1637 /// <param name="other">The collection to compare with.</param> 1638 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList64Bytes<T> other) 1639 where T : unmanaged, IEquatable<T> 1640 { 1641 foreach (var item in other) 1642 { 1643 container.Remove(item); 1644 } 1645 } 1646 1647 /// <summary> 1648 /// Removes the values from this set which are absent in another collection. 1649 /// </summary> 1650 /// <typeparam name="T">The type of values.</typeparam> 1651 /// <param name="container">The set to remove values from.</param> 1652 /// <param name="other">The collection to compare with.</param> 1653 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList64Bytes<T> other) 1654 where T : unmanaged, IEquatable<T> 1655 { 1656 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1657 1658 foreach (var item in other) 1659 { 1660 if (container.Contains(item)) 1661 { 1662 result.Add(item); 1663 } 1664 } 1665 1666 container.Clear(); 1667 container.UnionWith(result); 1668 1669 result.Dispose(); 1670 } 1671 1672 /// <summary> 1673 /// Adds all values from a collection to this set. 1674 /// </summary> 1675 /// <typeparam name="T">The type of values.</typeparam> 1676 /// <param name="container">The set to add values to.</param> 1677 /// <param name="other">The collection to copy values from.</param> 1678 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, FixedList64Bytes<T> other) 1679 where T : unmanaged, IEquatable<T> 1680 { 1681 foreach (var item in other) 1682 { 1683 container.Add(item); 1684 } 1685 } 1686 /// <summary> 1687 /// Removes the values from this set which are also present in another collection. 1688 /// </summary> 1689 /// <typeparam name="T">The type of values.</typeparam> 1690 /// <param name="container">The set to remove values from.</param> 1691 /// <param name="other">The collection to compare with.</param> 1692 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, NativeArray<T> other) 1693 where T : unmanaged, IEquatable<T> 1694 { 1695 foreach (var item in other) 1696 { 1697 container.Remove(item); 1698 } 1699 } 1700 1701 /// <summary> 1702 /// Removes the values from this set which are absent in another collection. 1703 /// </summary> 1704 /// <typeparam name="T">The type of values.</typeparam> 1705 /// <param name="container">The set to remove values from.</param> 1706 /// <param name="other">The collection to compare with.</param> 1707 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, NativeArray<T> other) 1708 where T : unmanaged, IEquatable<T> 1709 { 1710 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1711 1712 foreach (var item in other) 1713 { 1714 if (container.Contains(item)) 1715 { 1716 result.Add(item); 1717 } 1718 } 1719 1720 container.Clear(); 1721 container.UnionWith(result); 1722 1723 result.Dispose(); 1724 } 1725 1726 /// <summary> 1727 /// Adds all values from a collection to this set. 1728 /// </summary> 1729 /// <typeparam name="T">The type of values.</typeparam> 1730 /// <param name="container">The set to add values to.</param> 1731 /// <param name="other">The collection to copy values from.</param> 1732 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, NativeArray<T> other) 1733 where T : unmanaged, IEquatable<T> 1734 { 1735 foreach (var item in other) 1736 { 1737 container.Add(item); 1738 } 1739 } 1740 /// <summary> 1741 /// Removes the values from this set which are also present in another collection. 1742 /// </summary> 1743 /// <typeparam name="T">The type of values.</typeparam> 1744 /// <param name="container">The set to remove values from.</param> 1745 /// <param name="other">The collection to compare with.</param> 1746 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, NativeHashSet<T> other) 1747 where T : unmanaged, IEquatable<T> 1748 { 1749 foreach (var item in other) 1750 { 1751 container.Remove(item); 1752 } 1753 } 1754 1755 /// <summary> 1756 /// Removes the values from this set which are absent in another collection. 1757 /// </summary> 1758 /// <typeparam name="T">The type of values.</typeparam> 1759 /// <param name="container">The set to remove values from.</param> 1760 /// <param name="other">The collection to compare with.</param> 1761 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, NativeHashSet<T> other) 1762 where T : unmanaged, IEquatable<T> 1763 { 1764 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1765 1766 foreach (var item in other) 1767 { 1768 if (container.Contains(item)) 1769 { 1770 result.Add(item); 1771 } 1772 } 1773 1774 container.Clear(); 1775 container.UnionWith(result); 1776 1777 result.Dispose(); 1778 } 1779 1780 /// <summary> 1781 /// Adds all values from a collection to this set. 1782 /// </summary> 1783 /// <typeparam name="T">The type of values.</typeparam> 1784 /// <param name="container">The set to add values to.</param> 1785 /// <param name="other">The collection to copy values from.</param> 1786 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, NativeHashSet<T> other) 1787 where T : unmanaged, IEquatable<T> 1788 { 1789 foreach (var item in other) 1790 { 1791 container.Add(item); 1792 } 1793 } 1794 /// <summary> 1795 /// Removes the values from this set which are also present in another collection. 1796 /// </summary> 1797 /// <typeparam name="T">The type of values.</typeparam> 1798 /// <param name="container">The set to remove values from.</param> 1799 /// <param name="other">The collection to compare with.</param> 1800 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, NativeHashSet<T>.ReadOnly other) 1801 where T : unmanaged, IEquatable<T> 1802 { 1803 foreach (var item in other) 1804 { 1805 container.Remove(item); 1806 } 1807 } 1808 1809 /// <summary> 1810 /// Removes the values from this set which are absent in another collection. 1811 /// </summary> 1812 /// <typeparam name="T">The type of values.</typeparam> 1813 /// <param name="container">The set to remove values from.</param> 1814 /// <param name="other">The collection to compare with.</param> 1815 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, NativeHashSet<T>.ReadOnly other) 1816 where T : unmanaged, IEquatable<T> 1817 { 1818 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1819 1820 foreach (var item in other) 1821 { 1822 if (container.Contains(item)) 1823 { 1824 result.Add(item); 1825 } 1826 } 1827 1828 container.Clear(); 1829 container.UnionWith(result); 1830 1831 result.Dispose(); 1832 } 1833 1834 /// <summary> 1835 /// Adds all values from a collection to this set. 1836 /// </summary> 1837 /// <typeparam name="T">The type of values.</typeparam> 1838 /// <param name="container">The set to add values to.</param> 1839 /// <param name="other">The collection to copy values from.</param> 1840 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, NativeHashSet<T>.ReadOnly other) 1841 where T : unmanaged, IEquatable<T> 1842 { 1843 foreach (var item in other) 1844 { 1845 container.Add(item); 1846 } 1847 } 1848 /// <summary> 1849 /// Removes the values from this set which are also present in another collection. 1850 /// </summary> 1851 /// <typeparam name="T">The type of values.</typeparam> 1852 /// <param name="container">The set to remove values from.</param> 1853 /// <param name="other">The collection to compare with.</param> 1854 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeHashSet<T> other) 1855 where T : unmanaged, IEquatable<T> 1856 { 1857 foreach (var item in other) 1858 { 1859 container.Remove(item); 1860 } 1861 } 1862 1863 /// <summary> 1864 /// Removes the values from this set which are absent in another collection. 1865 /// </summary> 1866 /// <typeparam name="T">The type of values.</typeparam> 1867 /// <param name="container">The set to remove values from.</param> 1868 /// <param name="other">The collection to compare with.</param> 1869 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeHashSet<T> other) 1870 where T : unmanaged, IEquatable<T> 1871 { 1872 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1873 1874 foreach (var item in other) 1875 { 1876 if (container.Contains(item)) 1877 { 1878 result.Add(item); 1879 } 1880 } 1881 1882 container.Clear(); 1883 container.UnionWith(result); 1884 1885 result.Dispose(); 1886 } 1887 1888 /// <summary> 1889 /// Adds all values from a collection to this set. 1890 /// </summary> 1891 /// <typeparam name="T">The type of values.</typeparam> 1892 /// <param name="container">The set to add values to.</param> 1893 /// <param name="other">The collection to copy values from.</param> 1894 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeHashSet<T> other) 1895 where T : unmanaged, IEquatable<T> 1896 { 1897 foreach (var item in other) 1898 { 1899 container.Add(item); 1900 } 1901 } 1902 /// <summary> 1903 /// Removes the values from this set which are also present in another collection. 1904 /// </summary> 1905 /// <typeparam name="T">The type of values.</typeparam> 1906 /// <param name="container">The set to remove values from.</param> 1907 /// <param name="other">The collection to compare with.</param> 1908 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 1909 where T : unmanaged, IEquatable<T> 1910 { 1911 foreach (var item in other) 1912 { 1913 container.Remove(item); 1914 } 1915 } 1916 1917 /// <summary> 1918 /// Removes the values from this set which are absent in another collection. 1919 /// </summary> 1920 /// <typeparam name="T">The type of values.</typeparam> 1921 /// <param name="container">The set to remove values from.</param> 1922 /// <param name="other">The collection to compare with.</param> 1923 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 1924 where T : unmanaged, IEquatable<T> 1925 { 1926 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1927 1928 foreach (var item in other) 1929 { 1930 if (container.Contains(item)) 1931 { 1932 result.Add(item); 1933 } 1934 } 1935 1936 container.Clear(); 1937 container.UnionWith(result); 1938 1939 result.Dispose(); 1940 } 1941 1942 /// <summary> 1943 /// Adds all values from a collection to this set. 1944 /// </summary> 1945 /// <typeparam name="T">The type of values.</typeparam> 1946 /// <param name="container">The set to add values to.</param> 1947 /// <param name="other">The collection to copy values from.</param> 1948 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeHashSet<T>.ReadOnly other) 1949 where T : unmanaged, IEquatable<T> 1950 { 1951 foreach (var item in other) 1952 { 1953 container.Add(item); 1954 } 1955 } 1956 /// <summary> 1957 /// Removes the values from this set which are also present in another collection. 1958 /// </summary> 1959 /// <typeparam name="T">The type of values.</typeparam> 1960 /// <param name="container">The set to remove values from.</param> 1961 /// <param name="other">The collection to compare with.</param> 1962 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, NativeParallelHashSet<T> other) 1963 where T : unmanaged, IEquatable<T> 1964 { 1965 foreach (var item in other) 1966 { 1967 container.Remove(item); 1968 } 1969 } 1970 1971 /// <summary> 1972 /// Removes the values from this set which are absent in another collection. 1973 /// </summary> 1974 /// <typeparam name="T">The type of values.</typeparam> 1975 /// <param name="container">The set to remove values from.</param> 1976 /// <param name="other">The collection to compare with.</param> 1977 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, NativeParallelHashSet<T> other) 1978 where T : unmanaged, IEquatable<T> 1979 { 1980 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1981 1982 foreach (var item in other) 1983 { 1984 if (container.Contains(item)) 1985 { 1986 result.Add(item); 1987 } 1988 } 1989 1990 container.Clear(); 1991 container.UnionWith(result); 1992 1993 result.Dispose(); 1994 } 1995 1996 /// <summary> 1997 /// Adds all values from a collection to this set. 1998 /// </summary> 1999 /// <typeparam name="T">The type of values.</typeparam> 2000 /// <param name="container">The set to add values to.</param> 2001 /// <param name="other">The collection to copy values from.</param> 2002 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, NativeParallelHashSet<T> other) 2003 where T : unmanaged, IEquatable<T> 2004 { 2005 foreach (var item in other) 2006 { 2007 container.Add(item); 2008 } 2009 } 2010 /// <summary> 2011 /// Removes the values from this set which are also present in another collection. 2012 /// </summary> 2013 /// <typeparam name="T">The type of values.</typeparam> 2014 /// <param name="container">The set to remove values from.</param> 2015 /// <param name="other">The collection to compare with.</param> 2016 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 2017 where T : unmanaged, IEquatable<T> 2018 { 2019 foreach (var item in other) 2020 { 2021 container.Remove(item); 2022 } 2023 } 2024 2025 /// <summary> 2026 /// Removes the values from this set which are absent in another collection. 2027 /// </summary> 2028 /// <typeparam name="T">The type of values.</typeparam> 2029 /// <param name="container">The set to remove values from.</param> 2030 /// <param name="other">The collection to compare with.</param> 2031 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 2032 where T : unmanaged, IEquatable<T> 2033 { 2034 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 2035 2036 foreach (var item in other) 2037 { 2038 if (container.Contains(item)) 2039 { 2040 result.Add(item); 2041 } 2042 } 2043 2044 container.Clear(); 2045 container.UnionWith(result); 2046 2047 result.Dispose(); 2048 } 2049 2050 /// <summary> 2051 /// Adds all values from a collection to this set. 2052 /// </summary> 2053 /// <typeparam name="T">The type of values.</typeparam> 2054 /// <param name="container">The set to add values to.</param> 2055 /// <param name="other">The collection to copy values from.</param> 2056 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 2057 where T : unmanaged, IEquatable<T> 2058 { 2059 foreach (var item in other) 2060 { 2061 container.Add(item); 2062 } 2063 } 2064 /// <summary> 2065 /// Removes the values from this set which are also present in another collection. 2066 /// </summary> 2067 /// <typeparam name="T">The type of values.</typeparam> 2068 /// <param name="container">The set to remove values from.</param> 2069 /// <param name="other">The collection to compare with.</param> 2070 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeParallelHashSet<T> other) 2071 where T : unmanaged, IEquatable<T> 2072 { 2073 foreach (var item in other) 2074 { 2075 container.Remove(item); 2076 } 2077 } 2078 2079 /// <summary> 2080 /// Removes the values from this set which are absent in another collection. 2081 /// </summary> 2082 /// <typeparam name="T">The type of values.</typeparam> 2083 /// <param name="container">The set to remove values from.</param> 2084 /// <param name="other">The collection to compare with.</param> 2085 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeParallelHashSet<T> other) 2086 where T : unmanaged, IEquatable<T> 2087 { 2088 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 2089 2090 foreach (var item in other) 2091 { 2092 if (container.Contains(item)) 2093 { 2094 result.Add(item); 2095 } 2096 } 2097 2098 container.Clear(); 2099 container.UnionWith(result); 2100 2101 result.Dispose(); 2102 } 2103 2104 /// <summary> 2105 /// Adds all values from a collection to this set. 2106 /// </summary> 2107 /// <typeparam name="T">The type of values.</typeparam> 2108 /// <param name="container">The set to add values to.</param> 2109 /// <param name="other">The collection to copy values from.</param> 2110 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeParallelHashSet<T> other) 2111 where T : unmanaged, IEquatable<T> 2112 { 2113 foreach (var item in other) 2114 { 2115 container.Add(item); 2116 } 2117 } 2118 /// <summary> 2119 /// Removes the values from this set which are also present in another collection. 2120 /// </summary> 2121 /// <typeparam name="T">The type of values.</typeparam> 2122 /// <param name="container">The set to remove values from.</param> 2123 /// <param name="other">The collection to compare with.</param> 2124 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 2125 where T : unmanaged, IEquatable<T> 2126 { 2127 foreach (var item in other) 2128 { 2129 container.Remove(item); 2130 } 2131 } 2132 2133 /// <summary> 2134 /// Removes the values from this set which are absent in another collection. 2135 /// </summary> 2136 /// <typeparam name="T">The type of values.</typeparam> 2137 /// <param name="container">The set to remove values from.</param> 2138 /// <param name="other">The collection to compare with.</param> 2139 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 2140 where T : unmanaged, IEquatable<T> 2141 { 2142 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 2143 2144 foreach (var item in other) 2145 { 2146 if (container.Contains(item)) 2147 { 2148 result.Add(item); 2149 } 2150 } 2151 2152 container.Clear(); 2153 container.UnionWith(result); 2154 2155 result.Dispose(); 2156 } 2157 2158 /// <summary> 2159 /// Adds all values from a collection to this set. 2160 /// </summary> 2161 /// <typeparam name="T">The type of values.</typeparam> 2162 /// <param name="container">The set to add values to.</param> 2163 /// <param name="other">The collection to copy values from.</param> 2164 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeParallelHashSet<T>.ReadOnly other) 2165 where T : unmanaged, IEquatable<T> 2166 { 2167 foreach (var item in other) 2168 { 2169 container.Add(item); 2170 } 2171 } 2172 /// <summary> 2173 /// Removes the values from this set which are also present in another collection. 2174 /// </summary> 2175 /// <typeparam name="T">The type of values.</typeparam> 2176 /// <param name="container">The set to remove values from.</param> 2177 /// <param name="other">The collection to compare with.</param> 2178 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, NativeList<T> other) 2179 where T : unmanaged, IEquatable<T> 2180 { 2181 foreach (var item in other) 2182 { 2183 container.Remove(item); 2184 } 2185 } 2186 2187 /// <summary> 2188 /// Removes the values from this set which are absent in another collection. 2189 /// </summary> 2190 /// <typeparam name="T">The type of values.</typeparam> 2191 /// <param name="container">The set to remove values from.</param> 2192 /// <param name="other">The collection to compare with.</param> 2193 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, NativeList<T> other) 2194 where T : unmanaged, IEquatable<T> 2195 { 2196 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 2197 2198 foreach (var item in other) 2199 { 2200 if (container.Contains(item)) 2201 { 2202 result.Add(item); 2203 } 2204 } 2205 2206 container.Clear(); 2207 container.UnionWith(result); 2208 2209 result.Dispose(); 2210 } 2211 2212 /// <summary> 2213 /// Adds all values from a collection to this set. 2214 /// </summary> 2215 /// <typeparam name="T">The type of values.</typeparam> 2216 /// <param name="container">The set to add values to.</param> 2217 /// <param name="other">The collection to copy values from.</param> 2218 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, NativeList<T> other) 2219 where T : unmanaged, IEquatable<T> 2220 { 2221 foreach (var item in other) 2222 { 2223 container.Add(item); 2224 } 2225 } 2226 /// <summary> 2227 /// Removes the values from this set which are also present in another collection. 2228 /// </summary> 2229 /// <typeparam name="T">The type of values.</typeparam> 2230 /// <param name="container">The set to remove values from.</param> 2231 /// <param name="other">The collection to compare with.</param> 2232 public static void ExceptWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeList<T> other) 2233 where T : unmanaged, IEquatable<T> 2234 { 2235 foreach (var item in other) 2236 { 2237 container.Remove(item); 2238 } 2239 } 2240 2241 /// <summary> 2242 /// Removes the values from this set which are absent in another collection. 2243 /// </summary> 2244 /// <typeparam name="T">The type of values.</typeparam> 2245 /// <param name="container">The set to remove values from.</param> 2246 /// <param name="other">The collection to compare with.</param> 2247 public static void IntersectWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeList<T> other) 2248 where T : unmanaged, IEquatable<T> 2249 { 2250 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 2251 2252 foreach (var item in other) 2253 { 2254 if (container.Contains(item)) 2255 { 2256 result.Add(item); 2257 } 2258 } 2259 2260 container.Clear(); 2261 container.UnionWith(result); 2262 2263 result.Dispose(); 2264 } 2265 2266 /// <summary> 2267 /// Adds all values from a collection to this set. 2268 /// </summary> 2269 /// <typeparam name="T">The type of values.</typeparam> 2270 /// <param name="container">The set to add values to.</param> 2271 /// <param name="other">The collection to copy values from.</param> 2272 public static void UnionWith<T>(this ref UnsafeParallelHashSet<T> container, UnsafeList<T> other) 2273 where T : unmanaged, IEquatable<T> 2274 { 2275 foreach (var item in other) 2276 { 2277 container.Add(item); 2278 } 2279 } 2280 } 2281}