< Summary - SonghayCore

Information
Class: Songhay.Extensions.ArrayExtensions
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/ArrayExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 45
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
Next(...)0%40%
Previous(...)0%40%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/ArrayExtensions.cs

#LineLine coverage
 1namespace Songhay.Extensions;
 2
 3/// <summary>
 4/// Extensions of <see cref="Array"/>.
 5/// </summary>
 6public static class ArrayExtensions
 7{
 8    /// <summary>
 9    /// Gets the next item in the specified <see cref="Array"/>.
 10    /// </summary>
 11    /// <typeparam name="T">The array <see cref="Type"/>.</typeparam>
 12    /// <param name="array">The array.</param>
 13    /// <param name="item">The item.</param>
 14    public static T? Next<T>(this Array? array, T? item)
 015    {
 016        if (array == null) return default;
 17
 018        var indexOfKey = Array.IndexOf(array, item);
 19
 020        ++indexOfKey;
 21
 022        if (indexOfKey >= array.Length) return default(T);
 23
 024        return (T) array.GetValue(indexOfKey)!;
 025    }
 26
 27    /// <summary>
 28    /// Gets the previous item in the specified <see cref="Array"/>.
 29    /// </summary>
 30    /// <typeparam name="T">The array <see cref="Type"/>.</typeparam>
 31    /// <param name="array">The array.</param>
 32    /// <param name="item">The item.</param>
 33    public static T? Previous<T>(this Array? array, T? item)
 034    {
 035        if (array == null) return default;
 36
 037        var indexOfKey = Array.IndexOf(array, item);
 38
 039        --indexOfKey;
 40
 041        if (indexOfKey < 0) return default(T);
 42
 043        return (T) array.GetValue(indexOfKey)!;
 044    }
 45}