Class AdjacencyCollection<TInstruction>
- Namespace
- Echo.ControlFlow.Collections
- Assembly
- Echo.ControlFlow.dll
Represents a collection of edges originating from a single node.
public class AdjacencyCollection<TInstruction> : ICollection<ControlFlowEdge<TInstruction>>, IEnumerable<ControlFlowEdge<TInstruction>>, IEnumerable where TInstruction : notnull
Type Parameters
TInstructionThe type of data that each node stores.
- Inheritance
-
AdjacencyCollection<TInstruction>
- Implements
-
ICollection<ControlFlowEdge<TInstruction>>IEnumerable<ControlFlowEdge<TInstruction>>
- Inherited Members
Properties
Count
public int Count { get; }
Property Value
EdgeType
Gets the type of edges that are stored in this collection.
public ControlFlowEdgeType EdgeType { get; }
Property Value
IsReadOnly
public bool IsReadOnly { get; }
Property Value
Owner
Gets the node that all edges are originating from.
public ControlFlowNode<TInstruction> Owner { get; }
Property Value
- ControlFlowNode<TInstruction>
Methods
Add(ControlFlowEdge<TInstruction>)
Adds an edge to the adjacency collection.
public ControlFlowEdge<TInstruction> Add(ControlFlowEdge<TInstruction> edge)
Parameters
edgeControlFlowEdge<TInstruction>The edge to add.
Returns
- ControlFlowEdge<TInstruction>
The edge that was added.
Exceptions
- ArgumentException
Occurs when the provided edge cannot be added to this collection because of an invalid source node or edge type.
Add(ControlFlowNode<TInstruction>)
Creates and adds a edge to the provided node.
public ControlFlowEdge<TInstruction> Add(ControlFlowNode<TInstruction> neighbour)
Parameters
neighbourControlFlowNode<TInstruction>The new neighbouring node.
Returns
- ControlFlowEdge<TInstruction>
The created edge.
Clear()
public void Clear()
Contains(ControlFlowEdge<TInstruction>)
public bool Contains(ControlFlowEdge<TInstruction> item)
Parameters
itemControlFlowEdge<TInstruction>
Returns
Contains(ControlFlowNode<TInstruction>)
Determines whether a node is a neighbour of the current node. That is, determines whether there exists at least one edge between the current node and the provided node.
public bool Contains(ControlFlowNode<TInstruction> neighbour)
Parameters
neighbourControlFlowNode<TInstruction>The node to check.
Returns
- bool
Trueif the provided node is a neighbour,falseotherwise.
CopyTo(ControlFlowEdge<TInstruction>[], int)
public void CopyTo(ControlFlowEdge<TInstruction>[] array, int arrayIndex)
Parameters
arrayControlFlowEdge<TInstruction>[]arrayIndexint
GetEdgesToNeighbour(ControlFlowNode<TInstruction>)
Obtains all edges to the provided neighbour, if any.
public IEnumerable<ControlFlowEdge<TInstruction>> GetEdgesToNeighbour(ControlFlowNode<TInstruction> target)
Parameters
targetControlFlowNode<TInstruction>The neighbouring node.
Returns
- IEnumerable<ControlFlowEdge<TInstruction>>
The edges.
GetEnumerator()
public IEnumerator<ControlFlowEdge<TInstruction>> GetEnumerator()
Returns
- IEnumerator<ControlFlowEdge<TInstruction>>
Remove(ControlFlowEdge<TInstruction>)
public bool Remove(ControlFlowEdge<TInstruction> edge)
Parameters
edgeControlFlowEdge<TInstruction>
Returns
Remove(ControlFlowNode<TInstruction>)
Removes all edges originating from the current node to the provided neighbour.
public bool Remove(ControlFlowNode<TInstruction> neighbour)
Parameters
neighbourControlFlowNode<TInstruction>The neighbour to cut ties with.
Returns
- bool
Trueif at least one edge was removed,falseotherwise.