WeaverUtilities.

TopologicalSort<T>(List<T>, int, Func<T, IEnumerable<T>>, IEqualityComparer<T>, bool) Method

Summary

Sorts an array according to an array of dependants. If ItemA depends on ItemB, ItemA will be put later in the returned list. This method assigns a new list and releases the old one to the CollectionPool.
Assembly
Weaver.dll
Namespace
Weaver
Containing Type
WeaverUtilities

Syntax

public static void TopologicalSort<T>(ref List<T> list, int skip, Func<T, IEnumerable<T>> getDependancies, IEqualityComparer<T> comparer = null, bool ignoreCycles = false)

Type Parameters

Name Description
T

Parameters

Name Type Description
list List<T> The list to sort. If any element depends on something that isn't present, it will be added automatically.
skip int The index at which to start sorting. Everything before this index is kept in the same order as the input list.
getDependancies Func<T, IEnumerable<T>> A delegate that can return the dependancies of any given element.
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
void