Class NativeParallelMultiHashMapDataLayer<TKey, TItem>
Base class for all data layers that are based on NativeParallelMultiHashMap{TItem, TItem}.
Inheritance
Inherited Members
Namespace: Fwt.Core.DataLayers
Assembly: fwt.core.dll
Syntax
public abstract class NativeParallelMultiHashMapDataLayer<TKey, TItem> : DataLayer, IDisposable, ICommitChanges where TKey : unmanaged, IEquatable<TKey> where TItem : unmanaged
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the key to store a data under |
| TItem | Type of the data to store in the layer |
Fields
_data
Declaration
protected NativeParallelMultiHashMap<TKey, TItem> _data
Field Value
| Type | Description |
|---|---|
| NativeParallelMultiHashMap<TKey, TItem> |
Properties
Data
The container for data in the layer
Declaration
public NativeParallelMultiHashMap<TKey, TItem> Data { get; }
Property Value
| Type | Description |
|---|---|
| NativeParallelMultiHashMap<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 underlying multi hash map.
Declaration
public virtual void Clear()
Dispose()
Disposes the layer and all of it's data, calls DisposeAllItems() DisposeAllItems()
Declaration
public override void Dispose()
Overrides
DisposeAllItems()
Disposes all items in the layer by calling DisposeDataItem method for each item. DisposeDataItem(TItem)
Declaration
public override void DisposeAllItems()
Overrides
DisposeDataItem(TItem)
Disposes the item if it is IDisposable.
Declaration
protected virtual void DisposeDataItem(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item |
Init(int, Allocator)
Initializes/Reinitializes the data layer with the specified size. Requires a layer size, because in Jobs we need to know how much memory to allocate, so the underlying native multi hash map is created with capacity of layerSize.
Declaration
public virtual void Init(int layerSize, Allocator allocator = Allocator.Persistent)
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerSize | max amount of cells in the layer |
| Allocator | allocator | allocator to create an underlying collection with |
RemoveData(TKey)
Removes a data stored under the provided key.
Declaration
public virtual void RemoveData(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to remove a stored data under |
SetData(TKey, TItem)
Puts a data under the provided key.
Declaration
public virtual void SetData(TKey key, TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | Key to put data under |
| TItem | value | data to put under a provided key |
TryRemoveData(TKey)
Tries to remove a data stored under the provided key.
Declaration
public virtual bool TryRemoveData(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to remove a stored data under |
Returns
| Type | Description |
|---|---|
| bool | true if data was in the layer |
TrySetData(TKey, TItem)
Gets data stored under the provided key.
Declaration
public virtual bool TrySetData(TKey key, TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | key to search data under |
| TItem | value | value found under provided key. If nothing is found, then default value |
Returns
| Type | Description |
|---|---|
| bool | true if data was found, otherwise - false |