Class LazyBalancingOnRemoveStrategy<T, TChunk>
- Namespace
- NMF.Expressions.Linq
- Assembly
- NMF.Expressions.Chunk.dll
Denotes a base class for lazy balancing strategies for chunks
public class LazyBalancingOnRemoveStrategy<T, TChunk> : IChunkBalancingStrategyProvider<T, TChunk>
Type Parameters
T
The type of elements
TChunk
The type of chunks
- Inheritance
-
LazyBalancingOnRemoveStrategy<T, TChunk>
- Implements
-
IChunkBalancingStrategyProvider<T, TChunk>
- Inherited Members
- Extension Methods
Fields
Default
Denotes the default lazy balancing strategy
public static readonly LazyBalancingOnRemoveStrategy<T, TChunk> Default
Field Value
- LazyBalancingOnRemoveStrategy<T, TChunk>
Properties
RemoveFromOriginal
Determines whether the items shall be removed from their original chunk
protected virtual bool RemoveFromOriginal { get; }
Property Value
Methods
CanAdjust(TChunk)
Determines whether the given chunk can be adjusted
protected virtual bool CanAdjust(TChunk chunk)
Parameters
chunk
TChunkThe chunk to adjust
Returns
- bool
True, if the chunk can be modified, otherwise False
CanMove(TChunk, TChunk)
Determines whether elements can be moved between the given chunks
protected virtual bool CanMove(TChunk sourceChunk, TChunk targetChunk)
Parameters
sourceChunk
TChunkThe source chunk
targetChunk
TChunkThe target chunk
Returns
- bool
True, if moves are allowed, otherwise False
CreateStrategy(IObservableChunk<T, TChunk>)
Create a strategy for the given observable chunk collection
public IChunkBalancingStrategy<T, TChunk> CreateStrategy(IObservableChunk<T, TChunk> observableChunk)
Parameters
observableChunk
IObservableChunk<T, TChunk>The observable chunk collection
Returns
- IChunkBalancingStrategy<T, TChunk>
A chunk balancing strategy
GetChunkToRemove(IObservableChunk<T, TChunk>, int)
Gets the index of a chunk that can be targeted to remove
protected virtual int GetChunkToRemove(IObservableChunk<T, TChunk> observable, int chunkStartIndex)
Parameters
observable
IObservableChunk<T, TChunk>The observable chunk collection
chunkStartIndex
intThe start chunk index to look from
Returns
- int
The index of a chunk that could be targeted to save
Move(int, List<int>, IObservableChunk<T, TChunk>)
Moves the given element from one chunk to the other
protected virtual void Move(int sourceChunk, List<int> targetChunks, IObservableChunk<T, TChunk> observable)
Parameters
sourceChunk
intThe index of the source chunk
targetChunks
List<int>The index of the target chunk
observable
IObservableChunk<T, TChunk>The observable chunk collection
TryAddToExistingChunk(IObservableChunk<T, TChunk>, T, int)
Tries to add the item to an existing chunk
protected virtual bool TryAddToExistingChunk(IObservableChunk<T, TChunk> observable, T item, int sourceStartIndex)
Parameters
observable
IObservableChunk<T, TChunk>The observable chunk collection
item
TThe item that shall be added
sourceStartIndex
intThe index of the item in the source collection
Returns
- bool
True, if the item could be added to a chunk, otherwise False