Class TopoGraph<TKey, TItem>
Represents a generic DAG that can be topologically sorted.
Namespace: Umbraco.Core.Collections
Assembly: Umbraco.Core.dll
Syntax
public class TopoGraph<TKey, TItem> : TopoGraph
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys. |
TItem | The type of the items. |
Constructors
View SourceTopoGraph(Func<TItem, TKey>, Func<TItem, IEnumerable<TKey>>)
Initializes a new instance of the TopoGraph<TKey, TItem> class.
Declaration
public TopoGraph(Func<TItem, TKey> getKey, Func<TItem, IEnumerable<TKey>> getDependencies)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TItem, TKey> | getKey | A method that returns the key of an item. |
System.Func<TItem, System.Collections.Generic.IEnumerable<TKey>> | getDependencies | A method that returns the dependency keys of an item. |
Methods
View SourceAddItem(TItem)
Adds an item to the graph.
Declaration
public void AddItem(TItem item)
Parameters
Type | Name | Description |
---|---|---|
TItem | item | The item. |
AddItems(IEnumerable<TItem>)
Adds items to the graph.
Declaration
public void AddItems(IEnumerable<TItem> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | items | The items. |
GetSortedItems(Boolean, Boolean, Boolean)
Gets the sorted items.
Declaration
public IEnumerable<TItem> GetSortedItems(bool throwOnCycle = true, bool throwOnMissing = true, bool reverse = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | throwOnCycle | A value indicating whether to throw on cycles, or just ignore the branch. |
System.Boolean | throwOnMissing | A value indicating whether to throw on missing dependency, or just ignore the dependency. |
System.Boolean | reverse | A value indicating whether to reverse the order. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TItem> | The (topologically) sorted items. |