< Summary

Information
Class: MoreStructures.SuffixArrays.CyclicShifts.PcsUtils
Assembly: MoreStructures
File(s): /home/runner/work/MoreStructures/MoreStructures/MoreStructures/SuffixArrays/CyclicShifts/PcsUtils.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 48
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
ExtractPcsOf(...)100%1100%
ExtractPcsOf(...)100%2100%

File(s)

/home/runner/work/MoreStructures/MoreStructures/MoreStructures/SuffixArrays/CyclicShifts/PcsUtils.cs

#LineLine coverage
 1namespace MoreStructures.SuffixArrays.CyclicShifts;
 2
 3/// <summary>
 4/// Static class of utilities for partial cyclic shifts (PCS) of input strings.
 5/// </summary>
 6public static class PcsUtils
 7{
 8    /// <summary>
 9    /// Extracts the PCS of length <paramref name="pcsLength"/> from the provided <paramref name="input"/> string,
 10    /// together with their starting index in <paramref name="input"/>.
 11    /// </summary>
 12    /// <param name="input">The input string, to extract the PCS of length <paramref name="pcsLength"/> of.</param>
 13    /// <param name="pcsLength">The length of PCS to extract.</param>
 14    /// <returns>
 15    /// A sequence of strings, each one being a PCS. As many as the number of chars in the <paramref name="input"/>.
 16    /// </returns>
 17    /// <remarks>
 18    ///     <para id="complexity">
 19    ///     COMPLEXITY
 20    ///     <br/>
 21    ///     Time and Space Complexity is O(n * L).
 22    ///     </para>
 23    /// </remarks>
 24    public static IEnumerable<(string pcs, int index)> ExtractPcsOf(string input, int pcsLength) =>
 3925        from index in Enumerable.Range(0, input.Length)
 18726        let pcs = ExtractPcsOf(input, index, pcsLength)
 22627        select (pcs, index);
 28
 29    /// <summary>
 30    /// Extract the PCS of length <paramref name="pcsLength"/> from the provided <paramref name="input"/> string,
 31    /// starting at index <paramref name="index"/>.
 32    /// </summary>
 33    /// <param name="input">The input string, to extract the PCS of length <paramref name="pcsLength"/> of.</param>
 34    /// <param name="index">The starting index of the PCS to extract.</param>
 35    /// <param name="pcsLength">The length of the PCS to extract.</param>
 36    /// <returns>The string containing the PCS.</returns>
 37    /// <remarks>
 38    ///     <para id="complexity">
 39    ///     COMPLEXITY
 40    ///     <br/>
 41    ///     Time and Space Complexity is O(L).
 42    ///     </para>
 43    /// </remarks>
 44    public static string ExtractPcsOf(string input, int index, int pcsLength) =>
 30145        index + pcsLength <= input.Length
 30146            ? input[index..(index + pcsLength)]
 30147            : input[index..] + input[0..((index + pcsLength - input.Length) % input.Length)];
 48}