< Summary

Information
Class: DirectSight.Parser.Analysis.LineCoverage.ArrayBasedLineInfo<T>
Assembly DirectSight
File(s): /home/runner/work/DirectSight/DirectSight/DirectSight/Parser/Analysis/LineCoverage/ArrayBasedLineInfo.cs
Line coverage
91%
Covered lines: 34
Uncovered lines: 3
Coverable lines: 37
Total lines: 99
Line coverage: 91.8%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%44100%
GetEnumerator()100%22100%
System.Collections.IEnumerable.GetEnumerator()100%110%
Resize(...)100%11100%
Clone()100%11100%

File(s)

/home/runner/work/DirectSight/DirectSight/DirectSight/Parser/Analysis/LineCoverage/ArrayBasedLineInfo.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace DirectSight.Parser.Analysis.LineCoverage;
 5
 6/// <summary>
 7/// An implementation of <see cref="ILineInfo{T}"/> that uses an array to store the line information. This implementatio
 8/// </summary>
 9/// <typeparam name="T">The type of the elements in the line information.</typeparam>
 10internal class ArrayBasedLineInfo<T> : ILineInfo<T>
 11{
 12    /// <summary>
 13    /// The internal array that holds the line information. The length of this array is determined by the length specifi
 14    /// </summary>
 15    private readonly T[] data;
 16
 17    /// <summary>
 18    /// The default value used when initializing the array elements.
 19    /// </summary>
 20    private readonly T defaultValue;
 21
 22    /// <summary>
 23    /// Initializes a new instance of the <see cref="ArrayBasedLineInfo&lt;T&gt;"/> class.
 24    /// </summary>
 25    /// <param name="length">The number of elements to allocate for the internal data array. Must be non-negative.</para
 26    /// <param name="defaultValue">The default value to initialize each element with.</param>
 796827    public ArrayBasedLineInfo(long length, T defaultValue)
 796828    {
 796829        this.defaultValue = defaultValue;
 30
 796831        this.data = new T[length];
 32
 796833        if (EqualityComparer<T>.Default.Equals(defaultValue, default(T)))
 401534        {
 401535            return;
 36        }
 37
 12477038        for (long i = 0; i < length; i++)
 5843239        {
 5843240            this.data[i] = defaultValue;
 5843241        }
 796842    }
 43
 44    /// <inheritdoc />
 45    public int Length
 46    {
 47        get
 1864848        {
 1864849            return this.data.Length;
 1864850        }
 51    }
 52
 53    /// <inheritdoc />
 54    public long LongLength
 55    {
 56        get
 2912457        {
 2912458            return this.data.LongLength;
 2912459        }
 60    }
 61
 62    /// <inheritdoc />
 63    public T this[long index]
 64    {
 18959165        get => this.data[index];
 7649566        set => this.data[index] = value;
 67    }
 68
 69    /// <inheritdoc />
 70    public IEnumerator<T> GetEnumerator()
 487071    {
 29278072        foreach (var item in this.data)
 13958073        {
 13958074            yield return item;
 13859075        }
 388076    }
 77
 78    /// <inheritdoc />
 79    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 080    {
 081        return this.GetEnumerator();
 082    }
 83
 84    /// <inheritdoc />
 85    public ILineInfo<T> Resize(long length)
 91086    {
 91087        var newLineInfo = new ArrayBasedLineInfo<T>(length, this.defaultValue);
 88
 91089        Array.Copy(this.data, newLineInfo.data, Math.Min(this.data.LongLength, newLineInfo.data.LongLength));
 90
 91091        return newLineInfo;
 91092    }
 93
 94    /// <inheritdoc />
 95    public ILineInfo<T> Clone()
 90096    {
 90097        return this.Resize(this.LongLength);
 90098    }
 99}