< Summary

Information
Class: GridForge.Grids.Topology.GridCoveredAddressGeneration
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/Topology/GridCoveredAddressGeneration.cs
Line coverage
100%
Covered lines: 30
Uncovered lines: 0
Coverable lines: 30
Total lines: 78
Line coverage: 100%
Branch coverage
100%
Covered branches: 22
Total branches: 22
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%11100%
CompareTo(...)100%11100%
CompareConfigurationKeys(...)100%2222100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/Topology/GridCoveredAddressGeneration.cs

#LineLine coverage
 1//=======================================================================
 2// GridCoveredAddressGeneration.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 System;
 9using GridForge.Configuration;
 10
 11namespace GridForge.Grids.Topology;
 12
 13/// <summary>
 14/// Identifies one exact active grid generation eligible for a covered-address query.
 15/// </summary>
 16public readonly struct GridCoveredAddressGeneration : IComparable<GridCoveredAddressGeneration>
 17{
 18    /// <summary>The durable normalized grid identity.</summary>
 19    public GridConfigurationKey ConfigurationKey { get; }
 20
 21    /// <summary>The recyclable world-local grid slot.</summary>
 22    public ushort GridIndex { get; }
 23
 24    /// <summary>The exact process-unique grid allocation identity.</summary>
 25    public long GridSpawnToken { get; }
 26
 27    /// <summary>The last committed sequence applied to this grid generation.</summary>
 28    public ulong GridLastChangeSequence { get; }
 29
 30    /// <summary>Initializes an exact eligible grid-generation identity.</summary>
 31    public GridCoveredAddressGeneration(
 32        GridConfigurationKey configurationKey,
 33        ushort gridIndex,
 34        long gridSpawnToken,
 35        ulong gridLastChangeSequence)
 36    {
 42237        ConfigurationKey = configurationKey;
 42238        GridIndex = gridIndex;
 42239        GridSpawnToken = gridSpawnToken;
 42240        GridLastChangeSequence = gridLastChangeSequence;
 42241    }
 42
 43    /// <summary>
 44    /// Compares durable configuration identity only. Eligible inputs must be strictly ascending by this order.
 45    /// </summary>
 46    public int CompareTo(GridCoveredAddressGeneration other) =>
 8047        CompareConfigurationKeys(ConfigurationKey, other.ConfigurationKey);
 48
 49    internal static int CompareConfigurationKeys(
 50        GridConfigurationKey left,
 51        GridConfigurationKey right)
 52    {
 8053        int value = left.BoundsMin.X.CompareTo(right.BoundsMin.X);
 12154        if (value != 0) return value;
 3955        value = left.BoundsMin.Y.CompareTo(right.BoundsMin.Y);
 4156        if (value != 0) return value;
 3757        value = left.BoundsMin.Z.CompareTo(right.BoundsMin.Z);
 4258        if (value != 0) return value;
 3259        value = left.BoundsMax.X.CompareTo(right.BoundsMax.X);
 3460        if (value != 0) return value;
 3061        value = left.BoundsMax.Y.CompareTo(right.BoundsMax.Y);
 3462        if (value != 0) return value;
 2663        value = left.BoundsMax.Z.CompareTo(right.BoundsMax.Z);
 2864        if (value != 0) return value;
 2465        value = left.TopologyKind.CompareTo(right.TopologyKind);
 2666        if (value != 0) return value;
 2267        value = left.TopologyMetrics.CellRadius.CompareTo(right.TopologyMetrics.CellRadius);
 2468        if (value != 0) return value;
 2069        value = left.TopologyMetrics.CellWidth.CompareTo(right.TopologyMetrics.CellWidth);
 2270        if (value != 0) return value;
 1871        value = left.TopologyMetrics.LayerHeight.CompareTo(right.TopologyMetrics.LayerHeight);
 2072        if (value != 0) return value;
 1673        value = left.TopologyMetrics.CellLength.CompareTo(right.TopologyMetrics.CellLength);
 1674        return value != 0
 1675            ? value
 1676            : left.TopologyMetrics.HexOrientation.CompareTo(right.TopologyMetrics.HexOrientation);
 77    }
 78}