WeaverUtilities.

TopologicalSort<T>(IEnumerable<T>, IEnumerable<IDependant<T>>, IEqualityComparer<T>, bool) Method

Summary

Sorts a collection according to a collection of dependants. If ItemA depends on ItemB, ItemA will be put later in the returned list.
Assembly
Weaver.dll
Namespace
Weaver
Containing Type
WeaverUtilities

Syntax

public static List<T> TopologicalSort<T>(IEnumerable<T> collection, IEnumerable<IDependant<T>> dependants, IEqualityComparer<T> comparer = null, bool ignoreCycles = false)

Type Parameters

Name Description
T

Parameters

Name Type Description
collection IEnumerable<T> The collection to sort. If any element depends on something that isn't present, it will be added automatically.
dependants IEnumerable<IDependant<T>> An array which specifies what each element is dependant on.
comparer IEqualityComparer<T> The equality comparer to use. Null will use the default comparer.
ignoreCycles bool If false, an System.ArgumentException will be thrown when a cyclic dependancy is encountered

Return Value

Type Description
List<T>