NanoByte.Common  2.6.1
NanoByte.Common.Dispatch.Merge Class Reference

Provides utility methods for merging ICollection<T>s. More...

Static Public Member Functions

static void TwoWay< T > (IEnumerable< T > theirs, IEnumerable< T > mine, Action< T > added, Action< T > removed)
 Performs a 2-way merge on two collections. Changes required to theirs to reflect mine are emitted using callback delegates. More...
 
static void TwoWay< T, TAdded, TRemoved > (IEnumerable< T > theirs, IEnumerable< T > mine, ICollection< TAdded > added, ICollection< TRemoved > removed)
 Performs a 2-way merge on two collections. Changes required to theirs to reflect mine are recorded using differential lists. More...
 
static void ThreeWay< T > (IEnumerable< T > reference, IEnumerable< T > theirs, IEnumerable< T > mine, Action< T > added, Action< T > removed)
 Performs a 3-way merge on a set of collections. Changes between reference and theirs as they apply to mine are emitted using callback delegates. More...
 
static void ThreeWay< T, TAdded, TRemoved > (IEnumerable< T > reference, IEnumerable< T > theirs, IEnumerable< T > mine, ICollection< TAdded > added, ICollection< TRemoved > removed)
 Performs a 3-way merge on a set of collections. Changes between reference and theirs as they apply to mine are recorded using differential lists. More...
 

Detailed Description

Provides utility methods for merging ICollection<T>s.

Member Function Documentation

◆ ThreeWay< T >()

static void NanoByte.Common.Dispatch.Merge.ThreeWay< T > ( IEnumerable< T >  reference,
IEnumerable< T >  theirs,
IEnumerable< T >  mine,
Action< T >  added,
Action< T >  removed 
)
inlinestatic

Performs a 3-way merge on a set of collections. Changes between reference and theirs as they apply to mine are emitted using callback delegates.

Parameters
referenceA common baseline from which both theirs and mine were modified.
theirsThe foreign list with changes that shall be merged in.
mineThe local list that shall be updated with foreign changes.
addedCalled for every element that should be added to mine .
removedCalled for every element that should be removed from mine .

Modified elements are handled by calling removed for the old state and added for the new state.

Type Constraints
T :class 
T :IMergeable<T> 

◆ ThreeWay< T, TAdded, TRemoved >()

static void NanoByte.Common.Dispatch.Merge.ThreeWay< T, TAdded, TRemoved > ( IEnumerable< T >  reference,
IEnumerable< T >  theirs,
IEnumerable< T >  mine,
ICollection< TAdded >  added,
ICollection< TRemoved >  removed 
)
inlinestatic

Performs a 3-way merge on a set of collections. Changes between reference and theirs as they apply to mine are recorded using differential lists.

Parameters
referenceA common baseline from which both theirs and mine were modified.
theirsThe foreign list with changes that shall be merged in.
mineThe local list that shall be updated with foreign changes.
addedAll elements that should be added to mine are added to this list.
removedAll elements that should be removed from mine are added to this list.

Modified elements are handled by adding to removed for the old state and to added for the new state.

Type Constraints
T :class 
T :IMergeable<T> 
T :TAdded 
T :TRemoved 

◆ TwoWay< T >()

static void NanoByte.Common.Dispatch.Merge.TwoWay< T > ( IEnumerable< T >  theirs,
IEnumerable< T >  mine,
Action< T >  added,
Action< T >  removed 
)
inlinestatic

Performs a 2-way merge on two collections. Changes required to theirs to reflect mine are emitted using callback delegates.

Parameters
theirsThe foreign list with changes that shall be merged in.
mineThe local list that shall be updated with foreign changes.
addedCalled for every element that should be added to mine .
removedCalled for every element that should be removed from mine .

theirs and mine should use an internal hashmap for ICollection<T>.Contains for better performance.

◆ TwoWay< T, TAdded, TRemoved >()

static void NanoByte.Common.Dispatch.Merge.TwoWay< T, TAdded, TRemoved > ( IEnumerable< T >  theirs,
IEnumerable< T >  mine,
ICollection< TAdded >  added,
ICollection< TRemoved >  removed 
)
inlinestatic

Performs a 2-way merge on two collections. Changes required to theirs to reflect mine are recorded using differential lists.

Parameters
theirsThe foreign list with changes that shall be merged in.
mineThe local list that shall be updated with foreign changes.
addedAll elements that should be added to mine are added to this list.
removedAll elements that should be removed from mine are added to this list.

theirs and mine should use an internal hashmap for ICollection<T>.Contains for better performance.

Type Constraints
T :class 
T :TAdded 
T :TRemoved 

The documentation for this class was generated from the following file: