Class NativeParallelHashMapDataLayer<TKey, TItem>
Base class for all data layers that are based on NativeParallelHashMap{TItem, TItem}.
Inherited Members
Namespace: Fwt.Core.DataLayers
Assembly: fwt.core.dll
Syntax
public abstract class NativeParallelHashMapDataLayer<TKey, TItem> : DataLayer, IDisposable, ICommitChanges where TKey : unmanaged, IEquatable<TKey> where TItem : unmanaged
Type Parameters
| Name | Description |
|---|---|
| TKey | type of the key to store data under |
| TItem | type of the data to store in the layer |
Fields
_data
Declaration
protected NativeParallelHashMap<TKey, TItem> _data
Field Value
| Type | Description |
|---|---|
| NativeParallelHashMap<TKey, TItem> |
Properties
Data
Container for the data of the layer.
Declaration
public NativeParallelHashMap<TKey, TItem> Data { get; }
Property Value
| Type | Description |
|---|---|
| NativeParallelHashMap<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 the data item if it is IDisposable.
Declaration
protected virtual void DisposeDataItem(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | data item to dispose |
GetData(TKey)
Returns the data item stored under the specified key.
Declaration
public virtual TItem GetData(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to get data under |
Returns
| Type | Description |
|---|---|
| TItem | data stored under the provided key |
Init(int, Allocator)
Initializes/Reinitializes the data layer with the specified size. Requires a layer size to be specified because NativeParallelHashMap{TItem, TItem} can't be resized in Jobs.
Declaration
public virtual void Init(int layerSize, Allocator allocator = Allocator.Persistent)
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerSize | Max amount of data items in layer |
| Allocator | allocator | allocator to create internal collections with |
RemoveData(TKey)
Removes the data item stored under the specified key.
Declaration
public virtual void RemoveData(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to remove data under |
SetData(TKey, TItem)
Sets the data item under the specified 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 provided key |
Returns
| Type | Description |
|---|---|
| bool | true if data was added, otherwise - false |
TryGetData(TKey, out TItem)
Tries to get the data item stored under the specified key.
Declaration
public virtual bool TryGetData(TKey key, out TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to get data under |
| TItem | value | value under the provided key. If nothing found - default |
Returns
| Type | Description |
|---|---|
| bool | true if data was found, otherwise - false |
TryRemoveData(TKey)
Tries to remove the data item stored under the specified 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, otherwise - false |
TrySetData(TKey, TItem)
Tries to set the data item under the specified 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 store under the provided key |
Returns
| Type | Description |
|---|---|
| bool | true if data was added, otherwise - false |