< Summary

Information
Class: SwiftCollections.SwiftSparseMapState<T>
Assembly: SwiftCollections
File(s): /home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Serialization/State/SwiftSparseMapState.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 58
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 Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%44100%

File(s)

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

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

Methods/Properties

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