Class NativeHashMapExtensions
Provides extension methods for hash maps.
Namespace: Unity.Collections
Assembly: Unity.Collections.dll
Syntax
public static class NativeHashMapExtensions
Methods
GetUniqueKeyArray<TKey, TValue>(UnsafeMultiHashMap<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 UnsafeMultiHashMap<TKey, TValue> container, AllocatorManager.AllocatorHandle allocator) where TKey : struct, IEquatable<TKey>, IComparable<TKey> where TValue : struct
Parameters
Type | Name | Description |
---|---|---|
UnsafeMultiHashMap<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>(NativeMultiHashMap<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 NativeMultiHashMap<TKey, TValue> container, AllocatorManager.AllocatorHandle allocator) where TKey : struct, IEquatable<TKey>, IComparable<TKey> where TValue : struct
Parameters
Type | Name | Description |
---|---|---|
NativeMultiHashMap<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>(NativeHashMap<TKey, TValue>)
Returns a "bucket" view of this hash map.
Declaration
public static UnsafeHashMapBucketData GetUnsafeBucketData<TKey, TValue>(this NativeHashMap<TKey, TValue> container) where TKey : struct, IEquatable<TKey> where TValue : struct
Parameters
Type | Name | Description |
---|---|---|
NativeHashMap<TKey, TValue> | container | The hash map. |
Returns
Type | Description |
---|---|
UnsafeHashMapBucketData | 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 UnsafeHashMapBucketData.
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>(NativeMultiHashMap<TKey, TValue>)
Returns a "bucket" view of this multi hash map.
Declaration
public static UnsafeHashMapBucketData GetUnsafeBucketData<TKey, TValue>(this NativeMultiHashMap<TKey, TValue> container) where TKey : struct, IEquatable<TKey> where TValue : struct
Parameters
Type | Name | Description |
---|---|---|
NativeMultiHashMap<TKey, TValue> | container | The multi hash map. |
Returns
Type | Description |
---|---|
UnsafeHashMapBucketData | 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 UnsafeHashMapBucketData.
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>(NativeMultiHashMap<TKey, TValue>, TKey, TValue)
Removes all occurrences of a particular key-value pair.
Declaration
public static void Remove<TKey, TValue>(this NativeMultiHashMap<TKey, TValue> container, TKey key, TValue value) where TKey : struct, IEquatable<TKey> where TValue : struct, IEquatable<TValue>
Parameters
Type | Name | Description |
---|---|---|
NativeMultiHashMap<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 : struct, 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.