< Summary

Information
Class: SwiftCollections.SwiftSparseSetState<T>
Assembly: SwiftCollections
File(s): /home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Serialization/State/SwiftSparseSetState.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 51
Line coverage: 100%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)50%44100%

File(s)

/home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Serialization/State/SwiftSparseSetState.cs

#LineLine coverage
 1using MemoryPack;
 2using System;
 3using System.Text.Json.Serialization;
 4
 5namespace SwiftCollections;
 6
 7/// <summary>
 8/// Represents the immutable state of a sparse set, containing the dense keys and associated values.
 9/// </summary>
 10/// <remarks>
 11/// This structure is typically used to serialize or inspect the contents of a sparse set.
 12/// The arrays are guaranteed to be non-null, but may be empty if the set contains no elements.
 13/// </remarks>
 14/// <typeparam name="T">The type of values stored in the sparse set.</typeparam>
 15[Serializable]
 16[MemoryPackable]
 17public readonly partial struct SwiftSparseSetState<T>
 18{
 19    /// <summary>
 20    /// Gets the collection of dense keys associated with this instance.
 21    /// </summary>
 22    [JsonInclude]
 23    [MemoryPackInclude]
 24    public readonly int[] DenseKeys;
 25
 26    /// <summary>
 27    /// Gets the array containing the dense values for this instance.
 28    /// </summary>
 29    [JsonInclude]
 30    [MemoryPackInclude]
 31    public readonly T[] DenseValues;
 32
 33    /// <summary>
 34    /// Initializes a new instance of the SwiftSparseSetState class with the specified dense keys and values.
 35    /// </summary>
 36    /// <param name="denseKeys">
 37    /// An array of integers representing the dense keys to initialize the set with.
 38    /// If null, an empty array is used.
 39    /// </param>
 40    /// <param name="denseValues">
 41    /// An array of values of type T corresponding to the dense keys.
 42    /// If null, an empty array is used.
 43    /// </param>
 44    [JsonConstructor]
 45    [MemoryPackConstructor]
 46    public SwiftSparseSetState(int[] denseKeys, T[] denseValues)
 47    {
 1048        DenseKeys = denseKeys ?? Array.Empty<int>();
 1049        DenseValues = denseValues ?? Array.Empty<T>();
 1050    }
 51}

Methods/Properties

.ctor(System.Int32[],T[])