Search Results for

    Show / Hide Table of Contents

    Interface IStringifier<TEdge, TNode>

    A converter from IRecImmDictIndexedTreeNode<TEdge, TNode> structures and paths to string.

    Namespace: MoreStructures.RecImmTrees.Conversions
    Assembly: MoreStructures.dll
    Syntax
    public interface IStringifier<TEdge, TNode>
        where TEdge : IRecImmDictIndexedTreeEdge<TEdge, TNode> where TNode : IRecImmDictIndexedTreeNode<TEdge, TNode>
    Type Parameters
    Name Description
    TEdge

    The type of edges of the specific structure.

    TNode

    The type of nodes of the specific structure.

    Remarks

    REQUIREMENTS
    Requires TEdge to implement , so that output lines are sorted.

    COMPLEXITY
    Time Complexity = O(n) and Space Complexity = O(n) where n = number of nodes in the TNode structure/path. Each node and its incoming edge is visited once.

    Examples
    var stringifier = ...
    {
        NewLine = Environment.NewLine,
        Indent = '\t',
        RootStringifier = n => "R",
        EdgeAndNodeStringifier = (e, n) => $"{e} -> {n}",
    };
    var node = ...
    Console.WriteLine(stringifier.Stringify(node));

    Properties

    | Improve this Doc View Source

    EdgeAndNodeStringifier

    A function mapping the provided edge and node to a string. Used for all lines of the output but the first.

    Declaration
    Func<TEdge, TNode, string> EdgeAndNodeStringifier { get; set; }
    Property Value
    Type Description
    Func<TEdge, TNode, System.String>
    | Improve this Doc View Source

    Indent

    The character or string used to indent output, to visually express tree levels.

    Declaration
    string Indent { get; set; }
    Property Value
    Type Description
    System.String
    Examples

    2 or 4 spaces, a tab, ...

    | Improve this Doc View Source

    NewLine

    The character or string used to separate lines of the output.

    Declaration
    string NewLine { get; set; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    PathSeparator

    The character or string used to join stringified path nodes, when building the output string.

    Declaration
    string PathSeparator { get; set; }
    Property Value
    Type Description
    System.String
    Examples

    " -> ", ", ", ...

    | Improve this Doc View Source

    RootStringifier

    A function mapping the top-level node to a string. Used for the first line of the output.

    Declaration
    Func<TNode, string> RootStringifier { get; set; }
    Property Value
    Type Description
    Func<TNode, System.String>

    Methods

    | Improve this Doc View Source

    Stringify(TNode)

    Converts the provided IRecImmDictIndexedTreeNode<TEdge, TNode> into a string.

    Declaration
    string Stringify(TNode node)
    Parameters
    Type Name Description
    TNode node

    The root of the tree to stringify.

    Returns
    Type Description
    System.String

    A string version of the provided structure.

    Examples

    Using 4 spaces as indent, RootStringifier = n => "R", and EdgeAndNodeStringifier = (e, n) => $"{e} -> N":

    R
        e1 -> N
            e3 -> N
            e4 -> N
                e5 -> N
        e2 -> N
            e6 -> N
    | Improve this Doc View Source

    Stringify(TreePath<TEdge, TNode>)

    Converts the provided TreePath<TEdge, TNode> into a string.

    Declaration
    string Stringify(TreePath<TEdge, TNode> path)
    Parameters
    Type Name Description
    TreePath<TEdge, TNode> path

    The tree path to stringify.

    Returns
    Type Description
    System.String

    A string version of the provided path.

    Examples

    Using PathSeparator = " -> " and EdgeAndNodeStringifier = (e, n) => $"{e}":

    e1 -> e4 -> e5

    Extension Methods

    SuffixStructureNodeExtensions.GetAllSuffixesFor<TEdge, TNode>(TNode, TextWithTerminator)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX