public static IEnumerable <T> OrderByDependencies <T>(this IEnumerable <T> source, Func <T, IEnumerable <T> > getDependencies, bool throwOnCycle = true) { var sorted = new List <T>(); var visited = HashSetPool <T> .New(); foreach (var item in source) { OrderByDependenciesVisit(item, visited, sorted, getDependencies, throwOnCycle); } HashSetPool <T> .Free(visited); return(sorted); }
public static void Free <T>(this HashSet <T> hashSet) { HashSetPool <T> .Free(hashSet); }