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
TThe type of elements
TChunkThe 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
chunkTChunkThe 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
sourceChunkTChunkThe source chunk
targetChunkTChunkThe 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
observableChunkIObservableChunk<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
observableIObservableChunk<T, TChunk>The observable chunk collection
chunkStartIndexintThe 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
sourceChunkintThe index of the source chunk
targetChunksList<int>The index of the target chunk
observableIObservableChunk<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
observableIObservableChunk<T, TChunk>The observable chunk collection
itemTThe item that shall be added
sourceStartIndexintThe index of the item in the source collection
Returns
- bool
True, if the item could be added to a chunk, otherwise False