using System; using Unity.Collections.LowLevel.Unsafe; namespace Unity.Collections.LowLevel.Unsafe { /// /// Provides extension methods for sets. /// public unsafe static class HashSetExtensions { /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this NativeParallelHashSet container, UnsafeParallelHashSet other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this NativeParallelHashSet container, UnsafeParallelHashSet other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this NativeParallelHashSet container, UnsafeParallelHashSet other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this NativeParallelHashSet container, UnsafeList other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this NativeParallelHashSet container, UnsafeList other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this NativeParallelHashSet container, UnsafeList other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, FixedList128Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, FixedList128Bytes other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, FixedList128Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, FixedList32Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, FixedList32Bytes other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, FixedList32Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, FixedList4096Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, FixedList4096Bytes other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, FixedList4096Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, FixedList512Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, FixedList512Bytes other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, FixedList512Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, FixedList64Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, FixedList64Bytes other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, FixedList64Bytes other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, NativeArray other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, NativeArray other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, NativeArray other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, NativeParallelHashSet other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, NativeParallelHashSet other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, NativeParallelHashSet other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, NativeList other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, NativeList other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, NativeList other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, UnsafeParallelHashSet other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, UnsafeParallelHashSet other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, UnsafeParallelHashSet other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } /// /// Removes the values from this set which are also present in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void ExceptWith(this UnsafeParallelHashSet container, UnsafeList other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Remove(item); } } /// /// Removes the values from this set which are absent in another collection. /// /// The type of values. /// The set to remove values from. /// The collection to compare with. public static void IntersectWith(this UnsafeParallelHashSet container, UnsafeList other) where T : unmanaged, IEquatable { var result = new UnsafeList(container.Count(), Allocator.Temp); foreach (var item in other) { if (container.Contains(item)) { result.Add(item); } } container.Clear(); container.UnionWith(result); result.Dispose(); } /// /// Adds all values from a collection to this set. /// /// The type of values. /// The set to add values to. /// The collection to copy values from. public static void UnionWith(this UnsafeParallelHashSet container, UnsafeList other) where T : unmanaged, IEquatable { foreach (var item in other) { container.Add(item); } } } }