< Summary

Information
Class: MoreStructures.RecImmTrees.TreePath<T1, T2>
Assembly: MoreStructures
File(s): /home/runner/work/MoreStructures/MoreStructures/MoreStructures/RecImmTrees/TreePath.cs
Line coverage
100%
Covered lines: 49
Uncovered lines: 0
Coverable lines: 49
Total lines: 64
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
get_PathNodes()100%1100%
ToString()100%1100%

File(s)

/home/runner/work/MoreStructures/MoreStructures/MoreStructures/RecImmTrees/TreePath.cs

#LineLine coverage
 1using MoreStructures.RecImmTrees.Conversions;
 2using MoreStructures.Utilities;
 3
 4namespace MoreStructures.RecImmTrees;
 5
 6/// <summary>
 7/// An immutable sequence of <typeparamref name="TNode"/>, where each node is child of its predecessor and parent of
 8/// its successor and where node relationships are stored in <typeparamref name="TEdge"/> instances.
 9/// </summary>
 10/// <param name="PathNodes">The sequence of nodes respecting the parent-child relationship.</param>
 11/// <typeparam name="TEdge">The type of edges of the specific structure.</typeparam>
 12/// <typeparam name="TNode">The type of nodes of the specific structure.</typeparam>
 13/// <remarks>
 14/// Immutability is guaranteed by using <see cref="ValueReadOnlyDictionary{TKey, TValue}"/>.
 15/// </remarks>
 92016public record TreePath<TEdge, TNode>(IEnumerable<KeyValuePair<TEdge, TNode>> PathNodes)
 92017    where TEdge : IRecImmDictIndexedTreeEdge<TEdge, TNode>
 92018    where TNode : IRecImmDictIndexedTreeNode<TEdge, TNode>
 92019{
 92020    /// <summary>
 92021    /// Builds an empty path, i.e. an empty sequence of nodes.
 92022    /// </summary>
 4123    public TreePath() : this(Enumerable.Empty<KeyValuePair<TEdge, TNode>>())
 4124    {
 4125    }
 92026
 92027    /// <summary>
 92028    /// Builds a path composed of a single node with its incoming edge.
 92029    /// </summary>
 92030    /// <param name="edge">The edge leading to the node.</param>
 92031    /// <param name="node">The node defining the singleton path.</param>
 3332    public TreePath(TEdge edge, TNode node) : this(Enumerable.Repeat(KeyValuePair.Create(edge, node), 1))
 3333    {
 3334    }
 92035
 92036    /// <summary>
 92037    /// Builds a path composed of the provided couples of edges and nodes.
 92038    /// </summary>
 92039    /// <param name="pathNodes">An array of couples (edge, node).</param>
 92040    public TreePath(params (TEdge edge, TNode node)[] pathNodes)
 6841        : this(pathNodes.Select(pathNode => KeyValuePair.Create(pathNode.edge, pathNode.node)))
 2042    {
 2043    }
 92044
 92045    /// <summary>
 92046    /// A readonly view of the private collection of path <typeparamref name="TNode"/> instances.
 92047    /// </summary>
 100848    public IEnumerable<KeyValuePair<TEdge, TNode>> PathNodes { get; } =
 92049        PathNodes.ToValueReadOnlyCollection();
 92050
 251    private static readonly IStringifier<TEdge, TNode> Stringifier =
 3052        new FullyIterativeStringifier<TEdge, TNode>(r => string.Empty, (e, n) => $"{e}")
 253        {
 254            PathSeparator = " => ",
 255        };
 92056
 92057    /// <inheritdoc path="//*[not(self::summary)]"/>
 92058    /// <summary>
 92059    ///     <inheritdoc/>
 92060    ///     <br/>
 92061    ///     Uses a <see cref="IStringifier{TEdge, TNode}"/> to generate the string.
 92062    /// </summary>
 663    public override string ToString() => Stringifier.Stringify(this);
 92064}