Class ListDataLayer<TItem>
Base class for all data layers that are based on Array{T}.
Inherited Members
Namespace: Fwt.Core.DataLayers
Assembly: fwt.core.dll
Syntax
public abstract class ListDataLayer<TItem> : DataLayer, IDisposable, ICommitChanges, IListDataLayer<TItem>
Type Parameters
| Name | Description |
|---|---|
| TItem | Type of the items stored in the data layer |
Fields
_data
Declaration
protected List<TItem> _data
Field Value
| Type | Description |
|---|---|
| List<TItem> |
Properties
Data
The container for data in the layer.
Declaration
public List<TItem> Data { get; }
Property Value
| Type | Description |
|---|---|
| List<TItem> |
Length
Returns the number of items in the layer.
Declaration
public override int Length { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Methods
Dispose()
Disposes the data layer, calls DisposeAllItems() DisposeAllItems()
Declaration
public override void Dispose()
Overrides
DisposeAllItems()
Disposes all items in the data layer by calling DisposeDataItem() for each DisposeDataItem(TItem)
Declaration
public override void DisposeAllItems()
Overrides
DisposeDataItem(TItem)
Disposes the item in the data layer if it is IDisposable.
Declaration
protected virtual void DisposeDataItem(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item |
DisposeExcessItems(int)
Disposes items at cells greater than layerSize
Declaration
public virtual void DisposeExcessItems(int layerSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerSize | amount of items to keep, dispose remaining items |
GetData(int)
Returns the data at the specified index.
Declaration
public virtual TItem GetData(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to get data from |
Returns
| Type | Description |
|---|---|
| TItem | data found in a cell at provided index |
Init(int, Allocator)
Initializes/Reinitializes the data layer with the specified size.
Declaration
public virtual void Init(int layerSize, Allocator allocator = Allocator.Persistent)
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerSize | amount of cells in the layer |
| Allocator | allocator | allocator to create internal collections with. Used in a classes inherited from this data layer |
SetData(int, TItem)
Sets the data at the specified index.
Declaration
public virtual bool SetData(int index, TItem data)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to put data into |
| TItem | data | data to put into the cell at provided index |
Returns
| Type | Description |
|---|---|
| bool | true if data was set |
TryGetData(int, out TItem)
Tries to get the data at the specified index.
Declaration
public virtual bool TryGetData(int index, out TItem data)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to get data from |
| TItem | data | data found into the cell at provided index |
Returns
| Type | Description |
|---|---|
| bool | true if data was found |
TrySetData(int, TItem)
Tries to set the data at the specified index.
Declaration
public bool TrySetData(int index, TItem data)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | cell index to put data into |
| TItem | data | data to put into the cell at provided index |
Returns
| Type | Description |
|---|---|
| bool | true if data was set |