< Summary

Information
Class: MoreStructures.SuffixTrees.SuffixTreeEdge
Assembly: MoreStructures
File(s): /home/runner/work/MoreStructures/MoreStructures/MoreStructures/SuffixTrees/SuffixTreeEdge.cs
Line coverage
100%
Covered lines: 50
Uncovered lines: 0
Coverable lines: 50
Total lines: 67
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%4100%
get_Start()100%1100%
get_Length()100%1100%
CompareTo(...)100%4100%
Of(...)100%1100%
OfRotated(...)100%1100%
ToString()100%1100%

File(s)

/home/runner/work/MoreStructures/MoreStructures/MoreStructures/SuffixTrees/SuffixTreeEdge.cs

#LineLine coverage
 1using MoreStructures.SuffixStructures;
 2
 3namespace MoreStructures.SuffixTrees;
 4
 5/// <summary>
 6/// The index key of the collection of children of a <see cref="SuffixTreeNode"/>, which identifies a non-empty
 7/// substring in text used as a selector to navigate the <see cref="SuffixTreeNode"/> in text pattern matching.
 8/// </summary>
 9/// <param name="Start">
 10///     <inheritdoc cref="ISuffixStructureEdge{TEdge, TNode}.Start" path="/summary"/>
 11/// </param>
 12/// <param name="Length">
 13///     <inheritdoc cref="ISuffixStructureEdge{TEdge, TNode}.Length" path="/summary"/>
 14/// </param>
 15/// <remarks>
 16/// Supports <see cref="IComparable{T}"/>, by <see cref="Start"/> and <see cref="Length"/>, in this order.
 17/// </remarks>
 4382218public record SuffixTreeEdge(int Start, int Length)
 4382219    : ISuffixStructureEdge<SuffixTreeEdge, SuffixTreeNode>, IComparable<SuffixTreeEdge>
 4382220{
 4382221    /// <inheritdoc/>
 8254822    public int Start { get; init; } = Start >= 0
 4382523        ? Start
 4382524        : throw new ArgumentOutOfRangeException(nameof(Start), "Must be non-negative.");
 4382225
 4382226    /// <inheritdoc/>
 7814527    public int Length { get; init; } = Length >= 0
 4382328        ? Length
 4382329        : throw new ArgumentOutOfRangeException(nameof(Length), "Must be non-negative.");
 4382230
 4382231    /// <inheritdoc path="//*[not(self::summary)]"/>
 4382232    /// <summary>
 4382233    ///     <inheritdoc/>
 4382234    ///     <br/>
 4382235    ///     Comparison is done by <see cref="Start"/> first, then <see cref="Length"/>: lower is smaller, higher is
 4382236    ///     bigger.
 4382237    /// </summary>
 4382238    /// <exception cref="ArgumentException">
 4382239    /// Thrown when <paramref name="other"/> is not a <see cref="SuffixTreeEdge"/>.
 4382240    /// </exception>
 4382241    public int CompareTo(SuffixTreeEdge? other)
 112442    {
 112443        if (other == null)
 144            throw new ArgumentException($"Invalid comparison: cannot compare to null.");
 4382245
 112346        var startComparison = Start - other.Start;
 112347        if (startComparison != 0)
 112048            return startComparison;
 349        return Length - other.Length;
 112350    }
 4382251
 4382252    /// <inheritdoc/>
 4382253    public virtual string Of(TextWithTerminator text) =>
 532154        string.Concat(text[Start..(Start + Length)])[0..Length];
 4382255
 4382256    /// <inheritdoc/>
 4382257    public virtual string OfRotated(RotatedTextWithTerminator text) =>
 658        string.Concat(text[Start..(Start + Length)])[0..Length];
 4382259
 4382260    /// <inheritdoc path="//*[not(self::summary)]"/>
 4382261    /// <summary>
 4382262    ///     <inheritdoc/>
 4382263    ///     <br/>
 4382264    ///     Generates a string in the form "(<see cref="Start"/>, <see cref="Length"/>)".
 4382265    /// </summary>
 94766    public override string ToString() => $"({Start},{Length})";
 4382267}