Class NativeParallelHashMapExtensions
Provides extension methods for hash maps.
Namespace: Unity.Collections
Assembly: Unity.Collections.dll
Syntax
public static class NativeParallelHashMapExtensions
Methods
GetUniqueKeyArray<TKey, TValue>(UnsafeParallelMultiHashMap<TKey, TValue>, AllocatorHandle)
Returns an array populated with the unique keys from this multi hash map.
Declaration
public static (NativeArray<TKey>, int) GetUniqueKeyArray<TKey, TValue>(this UnsafeParallelMultiHashMap<TKey, TValue> container, AllocatorManager.AllocatorHandle allocator) where TKey : unmanaged, IEquatable<TKey>, IComparable<TKey> where TValue : unmanaged
Parameters
Type | Name | Description |
---|---|---|
UnsafeParallelMultiHashMap<TKey, TValue> | container | The multi hash map. |
AllocatorManager.AllocatorHandle | allocator | The allocator to use. |
Returns
Type | Description |
---|---|
(NativeArray<TKey>, int) | An array populated with the unique keys from this multi hash map. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys. |
TValue | The type of the values. |
GetUniqueKeyArray<TKey, TValue>(NativeParallelMultiHashMap<TKey, TValue>, AllocatorHandle)
Returns an array populated with the unique keys from this multi hash map.
Declaration
public static (NativeArray<TKey>, int) GetUniqueKeyArray<TKey, TValue>(this NativeParallelMultiHashMap<TKey, TValue> container, AllocatorManager.AllocatorHandle allocator) where TKey : unmanaged, IEquatable<TKey>, IComparable<TKey> where TValue : unmanaged
Parameters
Type | Name | Description |
---|---|---|
NativeParallelMultiHashMap<TKey, TValue> | container | The multi hash map. |
AllocatorManager.AllocatorHandle | allocator | The allocator to use. |
Returns
Type | Description |
---|---|
(NativeArray<TKey>, int) | An array populated with the unique keys from this multi hash map. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys. |
TValue | The type of the values. |
GetUnsafeBucketData<TKey, TValue>(NativeParallelHashMap<TKey, TValue>)
Returns a "bucket" view of this hash map.
Declaration
public static UnsafeParallelHashMapBucketData GetUnsafeBucketData<TKey, TValue>(this NativeParallelHashMap<TKey, TValue> container) where TKey : unmanaged, IEquatable<TKey> where TValue : unmanaged
Parameters
Type | Name | Description |
---|---|---|
NativeParallelHashMap<TKey, TValue> | container | The hash map. |
Returns
Type | Description |
---|---|
UnsafeParallelHashMapBucketData | A "bucket" view of this hash map. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys. |
TValue | The type of the values. |
Remarks
Internally, the elements of a hash map are split into buckets of type UnsafeParallelHashMapBucketData.
With buckets, a job can safely access the elements of a hash map concurrently as long as each individual bucket is accessed only from an individual thread. Effectively, it is not safe to read elements of an individual bucket concurrently, but it is safe to read elements of separate buckets concurrently.
GetUnsafeBucketData<TKey, TValue>(NativeParallelMultiHashMap<TKey, TValue>)
Returns a "bucket" view of this multi hash map.
Declaration
public static UnsafeParallelHashMapBucketData GetUnsafeBucketData<TKey, TValue>(this NativeParallelMultiHashMap<TKey, TValue> container) where TKey : unmanaged, IEquatable<TKey> where TValue : unmanaged
Parameters
Type | Name | Description |
---|---|---|
NativeParallelMultiHashMap<TKey, TValue> | container | The multi hash map. |
Returns
Type | Description |
---|---|
UnsafeParallelHashMapBucketData | A "bucket" view of this multi hash map. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys. |
TValue | The type of the values. |
Remarks
Internally, the elements of a hash map are split into buckets of type UnsafeParallelHashMapBucketData.
With buckets, a job can safely access the elements of a hash map concurrently as long as each individual bucket is accessed only from an individual thread. Effectively, it is not safe to read elements of an individual bucket concurrently, but it is safe to read elements of separate buckets concurrently.
Remove<TKey, TValue>(NativeParallelMultiHashMap<TKey, TValue>, TKey, TValue)
Removes all occurrences of a particular key-value pair.
Declaration
public static void Remove<TKey, TValue>(this NativeParallelMultiHashMap<TKey, TValue> container, TKey key, TValue value) where TKey : unmanaged, IEquatable<TKey> where TValue : unmanaged, IEquatable<TValue>
Parameters
Type | Name | Description |
---|---|---|
NativeParallelMultiHashMap<TKey, TValue> | container | The multi hash map. |
TKey | key | The key of the key-value pairs to remove. |
TValue | value | The value of the key-value pairs to remove. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys. |
TValue | The type of the values. |
Remarks
Removes all key-value pairs which have a particular key and which also have a particular value. In other words: (key AND value) rather than (key OR value).
Unique<T>(NativeArray<T>)
Removes duplicate values from this sorted array and returns the number of values remaining.
Declaration
public static int Unique<T>(this NativeArray<T> array) where T : unmanaged, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The array from which to remove duplicates. |
Returns
Type | Description |
---|---|
int | The number of unique elements in this array. |
Type Parameters
Name | Description |
---|---|
T | The type of values in the array. |
Remarks
Uses Equals
to determine whether values are duplicates.
Expects the array to already be sorted.
The remaining elements will be tightly packed at the front of the array.