Struct UnsafeHashMap<TKey, TValue>.ReadOnly
A read-only alias for the value of a UnsafeHashMap. Does not have its own allocated storage.
Namespace: Unity.Collections.LowLevel.Unsafe
Assembly: Unity.Collections.dll
Syntax
public struct UnsafeHashMap<TKey, TValue>.ReadOnly
Properties
Capacity
The number of key-value pairs that fit in the current allocation.
Declaration
public readonly int Capacity { get; }
Property Value
Type | Description |
---|---|
int | The number of key-value pairs that fit in the current allocation. |
Count
The current number of key-value pairs in this hash map.
Declaration
public readonly int Count { get; }
Property Value
Type | Description |
---|---|
int | The current number of key-value pairs in this hash map. |
IsCreated
Whether this hash map has been allocated (and not yet deallocated).
Declaration
public readonly bool IsCreated { get; }
Property Value
Type | Description |
---|---|
bool | True if this hash map has been allocated (and not yet deallocated). |
IsEmpty
Whether this hash map is empty.
Declaration
public readonly bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool | True if this hash map is empty or if the map has not been constructed. |
this[TKey]
Gets values by key.
Declaration
public readonly TValue this[TKey key] { get; }
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to look up. |
Property Value
Type | Description |
---|---|
TValue | The value associated with the key. |
Remarks
Getting a key that is not present will throw.
Exceptions
Type | Condition |
---|---|
ArgumentException | For getting, thrown if the key was not present. |
Methods
ContainsKey(TKey)
Returns true if a given key is present in this hash map.
Declaration
public readonly bool ContainsKey(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to look up. |
Returns
Type | Description |
---|---|
bool | True if the key was present. |
GetEnumerator()
Returns an enumerator over the key-value pairs of this hash map.
Declaration
public readonly UnsafeHashMap<TKey, TValue>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
UnsafeHashMap<TKey, TValue>.Enumerator | An enumerator over the key-value pairs of this hash map. |
GetKeyArray(AllocatorHandle)
Returns an array with a copy of all this hash map's keys (in no particular order).
Declaration
public readonly NativeArray<TKey> GetKeyArray(AllocatorManager.AllocatorHandle allocator)
Parameters
Type | Name | Description |
---|---|---|
AllocatorManager.AllocatorHandle | allocator | The allocator to use. |
Returns
Type | Description |
---|---|
NativeArray<TKey> | An array with a copy of all this hash map's keys (in no particular order). |
GetKeyValueArrays(AllocatorHandle)
Returns a NativeKeyValueArrays with a copy of all this hash map's keys and values.
Declaration
public readonly NativeKeyValueArrays<TKey, TValue> GetKeyValueArrays(AllocatorManager.AllocatorHandle allocator)
Parameters
Type | Name | Description |
---|---|---|
AllocatorManager.AllocatorHandle | allocator | The allocator to use. |
Returns
Type | Description |
---|---|
NativeKeyValueArrays<TKey, TValue> | A NativeKeyValueArrays with a copy of all this hash map's keys and values. |
Remarks
The key-value pairs are copied in no particular order. For all i
, Values[i]
will be the value associated with Keys[i]
.
GetValueArray(AllocatorHandle)
Returns an array with a copy of all this hash map's values (in no particular order).
Declaration
public readonly NativeArray<TValue> GetValueArray(AllocatorManager.AllocatorHandle allocator)
Parameters
Type | Name | Description |
---|---|---|
AllocatorManager.AllocatorHandle | allocator | The allocator to use. |
Returns
Type | Description |
---|---|
NativeArray<TValue> | An array with a copy of all this hash map's values (in no particular order). |
TryGetValue(TKey, out TValue)
Returns the value associated with a key.
Declaration
public readonly bool TryGetValue(TKey key, out TValue item)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to look up. |
TValue | item | Outputs the value associated with the key. Outputs default if the key was not present. |
Returns
Type | Description |
---|---|
bool | True if the key was present. |