A game about forced loneliness, made by TACStudios
at master 1200 lines 47 kB view raw
1using System; 2using Unity.Collections.LowLevel.Unsafe; 3 4namespace Unity.Collections 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, FixedList128Bytes<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, FixedList128Bytes<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, FixedList128Bytes<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, FixedList32Bytes<T> 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, FixedList32Bytes<T> 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, FixedList32Bytes<T> 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, FixedList4096Bytes<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, FixedList4096Bytes<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, FixedList4096Bytes<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, FixedList512Bytes<T> 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, FixedList512Bytes<T> 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, FixedList512Bytes<T> 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, FixedList64Bytes<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, FixedList64Bytes<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, FixedList64Bytes<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 NativeHashSet<T> container, NativeArray<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 NativeHashSet<T> container, NativeArray<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 NativeHashSet<T> container, NativeArray<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 NativeHashSet<T> container, NativeHashSet<T> 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 NativeHashSet<T> container, NativeHashSet<T> 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 NativeHashSet<T> container, NativeHashSet<T> 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 NativeHashSet<T> container, NativeHashSet<T>.ReadOnly 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 NativeHashSet<T> container, NativeHashSet<T>.ReadOnly 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 NativeHashSet<T> container, NativeHashSet<T>.ReadOnly 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 NativeHashSet<T> container, NativeParallelHashSet<T> 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 NativeHashSet<T> container, NativeParallelHashSet<T> 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 NativeHashSet<T> container, NativeParallelHashSet<T> 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 NativeHashSet<T> container, NativeParallelHashSet<T>.ReadOnly 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 NativeHashSet<T> container, NativeParallelHashSet<T>.ReadOnly 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 NativeHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 544 where T : unmanaged, IEquatable<T> 545 { 546 foreach (var item in other) 547 { 548 container.Add(item); 549 } 550 } 551 /// <summary> 552 /// Removes the values from this set which are also present in another collection. 553 /// </summary> 554 /// <typeparam name="T">The type of values.</typeparam> 555 /// <param name="container">The set to remove values from.</param> 556 /// <param name="other">The collection to compare with.</param> 557 public static void ExceptWith<T>(this ref NativeHashSet<T> container, NativeList<T> other) 558 where T : unmanaged, IEquatable<T> 559 { 560 foreach (var item in other) 561 { 562 container.Remove(item); 563 } 564 } 565 566 /// <summary> 567 /// Removes the values from this set which are absent in another collection. 568 /// </summary> 569 /// <typeparam name="T">The type of values.</typeparam> 570 /// <param name="container">The set to remove values from.</param> 571 /// <param name="other">The collection to compare with.</param> 572 public static void IntersectWith<T>(this ref NativeHashSet<T> container, NativeList<T> other) 573 where T : unmanaged, IEquatable<T> 574 { 575 var result = new UnsafeList<T>(container.Count, Allocator.Temp); 576 577 foreach (var item in other) 578 { 579 if (container.Contains(item)) 580 { 581 result.Add(item); 582 } 583 } 584 585 container.Clear(); 586 container.UnionWith(result); 587 588 result.Dispose(); 589 } 590 591 /// <summary> 592 /// Adds all values from a collection to this set. 593 /// </summary> 594 /// <typeparam name="T">The type of values.</typeparam> 595 /// <param name="container">The set to add values to.</param> 596 /// <param name="other">The collection to copy values from.</param> 597 public static void UnionWith<T>(this ref NativeHashSet<T> container, NativeList<T> other) 598 where T : unmanaged, IEquatable<T> 599 { 600 foreach (var item in other) 601 { 602 container.Add(item); 603 } 604 } 605 /// <summary> 606 /// Removes the values from this set which are also present in another collection. 607 /// </summary> 608 /// <typeparam name="T">The type of values.</typeparam> 609 /// <param name="container">The set to remove values from.</param> 610 /// <param name="other">The collection to compare with.</param> 611 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, FixedList128Bytes<T> other) 612 where T : unmanaged, IEquatable<T> 613 { 614 foreach (var item in other) 615 { 616 container.Remove(item); 617 } 618 } 619 620 /// <summary> 621 /// Removes the values from this set which are absent in another collection. 622 /// </summary> 623 /// <typeparam name="T">The type of values.</typeparam> 624 /// <param name="container">The set to remove values from.</param> 625 /// <param name="other">The collection to compare with.</param> 626 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, FixedList128Bytes<T> other) 627 where T : unmanaged, IEquatable<T> 628 { 629 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 630 631 foreach (var item in other) 632 { 633 if (container.Contains(item)) 634 { 635 result.Add(item); 636 } 637 } 638 639 container.Clear(); 640 container.UnionWith(result); 641 642 result.Dispose(); 643 } 644 645 /// <summary> 646 /// Adds all values from a collection to this set. 647 /// </summary> 648 /// <typeparam name="T">The type of values.</typeparam> 649 /// <param name="container">The set to add values to.</param> 650 /// <param name="other">The collection to copy values from.</param> 651 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, FixedList128Bytes<T> other) 652 where T : unmanaged, IEquatable<T> 653 { 654 foreach (var item in other) 655 { 656 container.Add(item); 657 } 658 } 659 /// <summary> 660 /// Removes the values from this set which are also present in another collection. 661 /// </summary> 662 /// <typeparam name="T">The type of values.</typeparam> 663 /// <param name="container">The set to remove values from.</param> 664 /// <param name="other">The collection to compare with.</param> 665 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, FixedList32Bytes<T> other) 666 where T : unmanaged, IEquatable<T> 667 { 668 foreach (var item in other) 669 { 670 container.Remove(item); 671 } 672 } 673 674 /// <summary> 675 /// Removes the values from this set which are absent in another collection. 676 /// </summary> 677 /// <typeparam name="T">The type of values.</typeparam> 678 /// <param name="container">The set to remove values from.</param> 679 /// <param name="other">The collection to compare with.</param> 680 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, FixedList32Bytes<T> other) 681 where T : unmanaged, IEquatable<T> 682 { 683 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 684 685 foreach (var item in other) 686 { 687 if (container.Contains(item)) 688 { 689 result.Add(item); 690 } 691 } 692 693 container.Clear(); 694 container.UnionWith(result); 695 696 result.Dispose(); 697 } 698 699 /// <summary> 700 /// Adds all values from a collection to this set. 701 /// </summary> 702 /// <typeparam name="T">The type of values.</typeparam> 703 /// <param name="container">The set to add values to.</param> 704 /// <param name="other">The collection to copy values from.</param> 705 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, FixedList32Bytes<T> other) 706 where T : unmanaged, IEquatable<T> 707 { 708 foreach (var item in other) 709 { 710 container.Add(item); 711 } 712 } 713 /// <summary> 714 /// Removes the values from this set which are also present in another collection. 715 /// </summary> 716 /// <typeparam name="T">The type of values.</typeparam> 717 /// <param name="container">The set to remove values from.</param> 718 /// <param name="other">The collection to compare with.</param> 719 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, FixedList4096Bytes<T> other) 720 where T : unmanaged, IEquatable<T> 721 { 722 foreach (var item in other) 723 { 724 container.Remove(item); 725 } 726 } 727 728 /// <summary> 729 /// Removes the values from this set which are absent in another collection. 730 /// </summary> 731 /// <typeparam name="T">The type of values.</typeparam> 732 /// <param name="container">The set to remove values from.</param> 733 /// <param name="other">The collection to compare with.</param> 734 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, FixedList4096Bytes<T> other) 735 where T : unmanaged, IEquatable<T> 736 { 737 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 738 739 foreach (var item in other) 740 { 741 if (container.Contains(item)) 742 { 743 result.Add(item); 744 } 745 } 746 747 container.Clear(); 748 container.UnionWith(result); 749 750 result.Dispose(); 751 } 752 753 /// <summary> 754 /// Adds all values from a collection to this set. 755 /// </summary> 756 /// <typeparam name="T">The type of values.</typeparam> 757 /// <param name="container">The set to add values to.</param> 758 /// <param name="other">The collection to copy values from.</param> 759 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, FixedList4096Bytes<T> other) 760 where T : unmanaged, IEquatable<T> 761 { 762 foreach (var item in other) 763 { 764 container.Add(item); 765 } 766 } 767 /// <summary> 768 /// Removes the values from this set which are also present in another collection. 769 /// </summary> 770 /// <typeparam name="T">The type of values.</typeparam> 771 /// <param name="container">The set to remove values from.</param> 772 /// <param name="other">The collection to compare with.</param> 773 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, FixedList512Bytes<T> other) 774 where T : unmanaged, IEquatable<T> 775 { 776 foreach (var item in other) 777 { 778 container.Remove(item); 779 } 780 } 781 782 /// <summary> 783 /// Removes the values from this set which are absent in another collection. 784 /// </summary> 785 /// <typeparam name="T">The type of values.</typeparam> 786 /// <param name="container">The set to remove values from.</param> 787 /// <param name="other">The collection to compare with.</param> 788 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, FixedList512Bytes<T> other) 789 where T : unmanaged, IEquatable<T> 790 { 791 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 792 793 foreach (var item in other) 794 { 795 if (container.Contains(item)) 796 { 797 result.Add(item); 798 } 799 } 800 801 container.Clear(); 802 container.UnionWith(result); 803 804 result.Dispose(); 805 } 806 807 /// <summary> 808 /// Adds all values from a collection to this set. 809 /// </summary> 810 /// <typeparam name="T">The type of values.</typeparam> 811 /// <param name="container">The set to add values to.</param> 812 /// <param name="other">The collection to copy values from.</param> 813 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, FixedList512Bytes<T> other) 814 where T : unmanaged, IEquatable<T> 815 { 816 foreach (var item in other) 817 { 818 container.Add(item); 819 } 820 } 821 /// <summary> 822 /// Removes the values from this set which are also present in another collection. 823 /// </summary> 824 /// <typeparam name="T">The type of values.</typeparam> 825 /// <param name="container">The set to remove values from.</param> 826 /// <param name="other">The collection to compare with.</param> 827 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, FixedList64Bytes<T> other) 828 where T : unmanaged, IEquatable<T> 829 { 830 foreach (var item in other) 831 { 832 container.Remove(item); 833 } 834 } 835 836 /// <summary> 837 /// Removes the values from this set which are absent in another collection. 838 /// </summary> 839 /// <typeparam name="T">The type of values.</typeparam> 840 /// <param name="container">The set to remove values from.</param> 841 /// <param name="other">The collection to compare with.</param> 842 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, FixedList64Bytes<T> other) 843 where T : unmanaged, IEquatable<T> 844 { 845 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 846 847 foreach (var item in other) 848 { 849 if (container.Contains(item)) 850 { 851 result.Add(item); 852 } 853 } 854 855 container.Clear(); 856 container.UnionWith(result); 857 858 result.Dispose(); 859 } 860 861 /// <summary> 862 /// Adds all values from a collection to this set. 863 /// </summary> 864 /// <typeparam name="T">The type of values.</typeparam> 865 /// <param name="container">The set to add values to.</param> 866 /// <param name="other">The collection to copy values from.</param> 867 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, FixedList64Bytes<T> other) 868 where T : unmanaged, IEquatable<T> 869 { 870 foreach (var item in other) 871 { 872 container.Add(item); 873 } 874 } 875 /// <summary> 876 /// Removes the values from this set which are also present in another collection. 877 /// </summary> 878 /// <typeparam name="T">The type of values.</typeparam> 879 /// <param name="container">The set to remove values from.</param> 880 /// <param name="other">The collection to compare with.</param> 881 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, NativeArray<T> other) 882 where T : unmanaged, IEquatable<T> 883 { 884 foreach (var item in other) 885 { 886 container.Remove(item); 887 } 888 } 889 890 /// <summary> 891 /// Removes the values from this set which are absent in another collection. 892 /// </summary> 893 /// <typeparam name="T">The type of values.</typeparam> 894 /// <param name="container">The set to remove values from.</param> 895 /// <param name="other">The collection to compare with.</param> 896 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, NativeArray<T> other) 897 where T : unmanaged, IEquatable<T> 898 { 899 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 900 901 foreach (var item in other) 902 { 903 if (container.Contains(item)) 904 { 905 result.Add(item); 906 } 907 } 908 909 container.Clear(); 910 container.UnionWith(result); 911 912 result.Dispose(); 913 } 914 915 /// <summary> 916 /// Adds all values from a collection to this set. 917 /// </summary> 918 /// <typeparam name="T">The type of values.</typeparam> 919 /// <param name="container">The set to add values to.</param> 920 /// <param name="other">The collection to copy values from.</param> 921 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, NativeArray<T> other) 922 where T : unmanaged, IEquatable<T> 923 { 924 foreach (var item in other) 925 { 926 container.Add(item); 927 } 928 } 929 /// <summary> 930 /// Removes the values from this set which are also present in another collection. 931 /// </summary> 932 /// <typeparam name="T">The type of values.</typeparam> 933 /// <param name="container">The set to remove values from.</param> 934 /// <param name="other">The collection to compare with.</param> 935 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, NativeHashSet<T> other) 936 where T : unmanaged, IEquatable<T> 937 { 938 foreach (var item in other) 939 { 940 container.Remove(item); 941 } 942 } 943 944 /// <summary> 945 /// Removes the values from this set which are absent in another collection. 946 /// </summary> 947 /// <typeparam name="T">The type of values.</typeparam> 948 /// <param name="container">The set to remove values from.</param> 949 /// <param name="other">The collection to compare with.</param> 950 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, NativeHashSet<T> other) 951 where T : unmanaged, IEquatable<T> 952 { 953 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 954 955 foreach (var item in other) 956 { 957 if (container.Contains(item)) 958 { 959 result.Add(item); 960 } 961 } 962 963 container.Clear(); 964 container.UnionWith(result); 965 966 result.Dispose(); 967 } 968 969 /// <summary> 970 /// Adds all values from a collection to this set. 971 /// </summary> 972 /// <typeparam name="T">The type of values.</typeparam> 973 /// <param name="container">The set to add values to.</param> 974 /// <param name="other">The collection to copy values from.</param> 975 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, NativeHashSet<T> other) 976 where T : unmanaged, IEquatable<T> 977 { 978 foreach (var item in other) 979 { 980 container.Add(item); 981 } 982 } 983 /// <summary> 984 /// Removes the values from this set which are also present in another collection. 985 /// </summary> 986 /// <typeparam name="T">The type of values.</typeparam> 987 /// <param name="container">The set to remove values from.</param> 988 /// <param name="other">The collection to compare with.</param> 989 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, NativeHashSet<T>.ReadOnly other) 990 where T : unmanaged, IEquatable<T> 991 { 992 foreach (var item in other) 993 { 994 container.Remove(item); 995 } 996 } 997 998 /// <summary> 999 /// Removes the values from this set which are absent in another collection. 1000 /// </summary> 1001 /// <typeparam name="T">The type of values.</typeparam> 1002 /// <param name="container">The set to remove values from.</param> 1003 /// <param name="other">The collection to compare with.</param> 1004 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, NativeHashSet<T>.ReadOnly other) 1005 where T : unmanaged, IEquatable<T> 1006 { 1007 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1008 1009 foreach (var item in other) 1010 { 1011 if (container.Contains(item)) 1012 { 1013 result.Add(item); 1014 } 1015 } 1016 1017 container.Clear(); 1018 container.UnionWith(result); 1019 1020 result.Dispose(); 1021 } 1022 1023 /// <summary> 1024 /// Adds all values from a collection to this set. 1025 /// </summary> 1026 /// <typeparam name="T">The type of values.</typeparam> 1027 /// <param name="container">The set to add values to.</param> 1028 /// <param name="other">The collection to copy values from.</param> 1029 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, NativeHashSet<T>.ReadOnly other) 1030 where T : unmanaged, IEquatable<T> 1031 { 1032 foreach (var item in other) 1033 { 1034 container.Add(item); 1035 } 1036 } 1037 /// <summary> 1038 /// Removes the values from this set which are also present in another collection. 1039 /// </summary> 1040 /// <typeparam name="T">The type of values.</typeparam> 1041 /// <param name="container">The set to remove values from.</param> 1042 /// <param name="other">The collection to compare with.</param> 1043 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, NativeParallelHashSet<T> other) 1044 where T : unmanaged, IEquatable<T> 1045 { 1046 foreach (var item in other) 1047 { 1048 container.Remove(item); 1049 } 1050 } 1051 1052 /// <summary> 1053 /// Removes the values from this set which are absent in another collection. 1054 /// </summary> 1055 /// <typeparam name="T">The type of values.</typeparam> 1056 /// <param name="container">The set to remove values from.</param> 1057 /// <param name="other">The collection to compare with.</param> 1058 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, NativeParallelHashSet<T> other) 1059 where T : unmanaged, IEquatable<T> 1060 { 1061 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1062 1063 foreach (var item in other) 1064 { 1065 if (container.Contains(item)) 1066 { 1067 result.Add(item); 1068 } 1069 } 1070 1071 container.Clear(); 1072 container.UnionWith(result); 1073 1074 result.Dispose(); 1075 } 1076 1077 /// <summary> 1078 /// Adds all values from a collection to this set. 1079 /// </summary> 1080 /// <typeparam name="T">The type of values.</typeparam> 1081 /// <param name="container">The set to add values to.</param> 1082 /// <param name="other">The collection to copy values from.</param> 1083 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, NativeParallelHashSet<T> other) 1084 where T : unmanaged, IEquatable<T> 1085 { 1086 foreach (var item in other) 1087 { 1088 container.Add(item); 1089 } 1090 } 1091 /// <summary> 1092 /// Removes the values from this set which are also present in another collection. 1093 /// </summary> 1094 /// <typeparam name="T">The type of values.</typeparam> 1095 /// <param name="container">The set to remove values from.</param> 1096 /// <param name="other">The collection to compare with.</param> 1097 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 1098 where T : unmanaged, IEquatable<T> 1099 { 1100 foreach (var item in other) 1101 { 1102 container.Remove(item); 1103 } 1104 } 1105 1106 /// <summary> 1107 /// Removes the values from this set which are absent in another collection. 1108 /// </summary> 1109 /// <typeparam name="T">The type of values.</typeparam> 1110 /// <param name="container">The set to remove values from.</param> 1111 /// <param name="other">The collection to compare with.</param> 1112 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 1113 where T : unmanaged, IEquatable<T> 1114 { 1115 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1116 1117 foreach (var item in other) 1118 { 1119 if (container.Contains(item)) 1120 { 1121 result.Add(item); 1122 } 1123 } 1124 1125 container.Clear(); 1126 container.UnionWith(result); 1127 1128 result.Dispose(); 1129 } 1130 1131 /// <summary> 1132 /// Adds all values from a collection to this set. 1133 /// </summary> 1134 /// <typeparam name="T">The type of values.</typeparam> 1135 /// <param name="container">The set to add values to.</param> 1136 /// <param name="other">The collection to copy values from.</param> 1137 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, NativeParallelHashSet<T>.ReadOnly other) 1138 where T : unmanaged, IEquatable<T> 1139 { 1140 foreach (var item in other) 1141 { 1142 container.Add(item); 1143 } 1144 } 1145 /// <summary> 1146 /// Removes the values from this set which are also present in another collection. 1147 /// </summary> 1148 /// <typeparam name="T">The type of values.</typeparam> 1149 /// <param name="container">The set to remove values from.</param> 1150 /// <param name="other">The collection to compare with.</param> 1151 public static void ExceptWith<T>(this ref NativeParallelHashSet<T> container, NativeList<T> other) 1152 where T : unmanaged, IEquatable<T> 1153 { 1154 foreach (var item in other) 1155 { 1156 container.Remove(item); 1157 } 1158 } 1159 1160 /// <summary> 1161 /// Removes the values from this set which are absent in another collection. 1162 /// </summary> 1163 /// <typeparam name="T">The type of values.</typeparam> 1164 /// <param name="container">The set to remove values from.</param> 1165 /// <param name="other">The collection to compare with.</param> 1166 public static void IntersectWith<T>(this ref NativeParallelHashSet<T> container, NativeList<T> other) 1167 where T : unmanaged, IEquatable<T> 1168 { 1169 var result = new UnsafeList<T>(container.Count(), Allocator.Temp); 1170 1171 foreach (var item in other) 1172 { 1173 if (container.Contains(item)) 1174 { 1175 result.Add(item); 1176 } 1177 } 1178 1179 container.Clear(); 1180 container.UnionWith(result); 1181 1182 result.Dispose(); 1183 } 1184 1185 /// <summary> 1186 /// Adds all values from a collection to this set. 1187 /// </summary> 1188 /// <typeparam name="T">The type of values.</typeparam> 1189 /// <param name="container">The set to add values to.</param> 1190 /// <param name="other">The collection to copy values from.</param> 1191 public static void UnionWith<T>(this ref NativeParallelHashSet<T> container, NativeList<T> other) 1192 where T : unmanaged, IEquatable<T> 1193 { 1194 foreach (var item in other) 1195 { 1196 container.Add(item); 1197 } 1198 } 1199 } 1200}