Class HashSetDataLayer<TItem>
Base class for all data layers that use HashSet as a data structure.
Inherited Members
Namespace: Fwt.Core.DataLayers
Assembly: fwt.core.dll
Syntax
public abstract class HashSetDataLayer<TItem> : DataLayer, IDisposable, ICommitChanges where TItem : IEquatable<TItem>
Type Parameters
| Name | Description |
|---|---|
| TItem |
Fields
_data
Declaration
protected HashSet<TItem> _data
Field Value
| Type | Description |
|---|---|
| HashSet<TItem> |
Properties
Data
Container for the data of the layer
Declaration
public HashSet<TItem> Data { get; }
Property Value
| Type | Description |
|---|---|
| HashSet<TItem> |
Length
Returns the number of items in the layer.
Declaration
public override int Length { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Methods
Add(TItem)
Adds data to the underlying hash set
Declaration
public virtual bool Add(TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | value | value to add |
Returns
| Type | Description |
|---|---|
| bool | true if data was added |
Contains(TItem)
Checks if the underlying hash set contains the value
Declaration
public virtual bool Contains(TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | value | value to check if layer contains |
Returns
| Type | Description |
|---|---|
| bool | true if data is in the layer, otherwise - false |
DisposeAllItems()
Disposes all items in the underlying hash set by calling DisposeDataItem() method for each item DisposeDataItem(TItem)
Declaration
public override void DisposeAllItems()
Overrides
DisposeDataItem(TItem)
Disposes provided item if it is IDisposable.
Declaration
protected virtual void DisposeDataItem(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | item to dispose |
Init(int, Allocator)
Initializes/Reinitializes the data layer with a given size.
Declaration
public virtual void Init(int layerSize, Allocator allocator = Allocator.Persistent)
Parameters
| Type | Name | Description |
|---|---|---|
| int | layerSize | size of the data layer (cells count) |
| Allocator | allocator | allocator to create internal collections. Used in classes inherited from this data layer |
Remove(TItem)
Removes data from the underlying hash set
Declaration
public virtual bool Remove(TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | value | value to remove from layer |
Returns
| Type | Description |
|---|---|
| bool | true if data was in the data layer |
SafeAdd(TItem)
Checks if the underlying hash set is not null. If hash set is not null, adds the value by calling Add() method Add(TItem).
Declaration
public virtual bool SafeAdd(TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | value | value to add into the underlying hash set |
Returns
| Type | Description |
|---|---|
| bool | true if data was added |
SafeContains(TItem)
Checks if the underlying hash set is not null. If hash set is not null, checks if it contains the value by calling Contains() method Contains(TItem).
Declaration
public virtual bool SafeContains(TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | value | value to check if it is present in the underlying hash set |
Returns
| Type | Description |
|---|---|
| bool | true if data is in the hash set, otherwise - false |
SafeRemove(TItem)
Checks if the underlying hash set is not null. If hash set is not null, removes the value by calling Remove() method Remove(TItem).
Declaration
public virtual bool SafeRemove(TItem value)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | value | value to remove from underlying hash set |
Returns
| Type | Description |
|---|---|
| bool | true if data was in a data layer |