Class DependencyLoopChecker<T>
Implements
Inherited Members
Namespace: LemonEdge.Utils
Assembly: LemonEdge.Utils.dll
Syntax
public class DependencyLoopChecker<T> : IDependencyLoopChecker<T>
Type Parameters
Name | Description |
---|---|
T |
Constructors
DependencyLoopChecker(Func<T, DependencyLoopItem<T>>)
Creates a new DependencyLoopChecker<T>.
Declaration
public DependencyLoopChecker(Func<T, DependencyLoopItem<T>> map)
Parameters
Type | Name | Description |
---|---|---|
Func<T, DependencyLoopItem<T>> | map | The function that maps T to DependencyLoopItem<T>. |
Methods
AddDependency(T)
Adds an item to the internal list for checking.
Declaration
public void AddDependency(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Your item |
HasLoop()
Checks all items added via AddDependency(T), and breaks at the first loop that is found.
Declaration
public bool HasLoop()
Returns
Type | Description |
---|---|
bool | Whether a loop was found |
PrintLooped()
Prints out the results found after calling HasLoop().
Declaration
public (string Output, T?[] Looped) PrintLooped()
Returns
Type | Description |
---|---|
(string Output, T[] Looped) | A string output of the first loop found, and the list of items. |
RemoveLooped()
Removes the looping items discovered by calling HasLoop(). HasLoop() breaks at the first loop found. Use this to remove that first round of items, then repeat.
Declaration
public T?[] RemoveLooped()
Returns
Type | Description |
---|---|
T[] | The removed items |
Reset()
Resets the internal lists for reuse.
Declaration
public void Reset()