Class NativeHashMapDataLayer<TKey, TItem>
Base class for all data layers that are based on NativeHashMap{TItem, TItem}.
Inherited Members
Namespace: Fwt.Core.DataLayers
Assembly: fwt.core.dll
Syntax
public abstract class NativeHashMapDataLayer<TKey, TItem> : DataLayer, IDisposable, ICommitChanges where TKey : unmanaged, IEquatable<TKey> where TItem : unmanaged
Type Parameters
| Name | Description |
|---|---|
| TKey | key type to store data under |
| TItem | type of data stored in the layer |
Fields
_data
Declaration
protected NativeHashMap<TKey, TItem> _data
Field Value
| Type | Description |
|---|---|
| NativeHashMap<TKey, TItem> |
Properties
Data
Container for data in the layer.
Declaration
public NativeHashMap<TKey, TItem> Data { get; }
Property Value
| Type | Description |
|---|---|
| NativeHashMap<TKey, TItem> |
Length
Number of items in the layer.
Declaration
public override int Length { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Methods
Clear()
Clears the data layer.
Declaration
public virtual void Clear()
Dispose()
Disposes the data layer, calls DisposeAllItems() DisposeAllItems()
Declaration
public override void Dispose()
Overrides
DisposeAllItems()
Disposes all items in the layer by calling DisposeDataItem for each DisposeDataItem(TItem)
Declaration
public override void DisposeAllItems()
Overrides
DisposeDataItem(TItem)
Disposes a data item if it is IDisposable.
Declaration
protected virtual void DisposeDataItem(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item |
GetData(TKey)
returns a data item stored under the key.
Declaration
public virtual TItem GetData(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to get data under |
Returns
| Type | Description |
|---|---|
| TItem | item stored under the provided key |
Init(int, Allocator)
Initializes/Reinitializes the data layer. Requires a layer size because NativeHashMap{TItem, TItem} can not be resized in Jobs.
Declaration
public virtual void Init(int layerSize, Allocator allocator = Allocator.Persistent)
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerSize | |
| Allocator | allocator |
RemoveData(TKey)
Removes a data item stored under the key.
Declaration
public virtual void RemoveData(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to remove data under |
SetData(TKey, TItem)
Sets a data item under the key.
Declaration
public virtual bool SetData(TKey key, TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to store data under |
| TItem | value | data to store under the provided key |
Returns
| Type | Description |
|---|---|
| bool | true if data was set |
TryGetData(TKey, out TItem)
Tries to get a data item stored under the key.
Declaration
public virtual bool TryGetData(TKey key, out TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to get data under |
| TItem | value | data found under the provided key. If not found = default |
Returns
| Type | Description |
|---|---|
| bool | true if data was found, otherwise - false |
TryRemoveData(TKey)
Tries to remove a data item stored under the key.
Declaration
public virtual bool TryRemoveData(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to remove data under |
Returns
| Type | Description |
|---|---|
| bool | true if data was in the layer |
TrySetData(TKey, TItem)
Tries to set a data item under the key.
Declaration
public virtual bool TrySetData(TKey key, TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to store data under |
| TItem | value | data to put under the provided key |
Returns
| Type | Description |
|---|---|
| bool | true if data was added |