< 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    {
 7737        ConfigurationKey = configurationKey;
 7738        GridIndex = gridIndex;
 7739        GridSpawnToken = gridSpawnToken;
 7740        GridLastChangeSequence = gridLastChangeSequence;
 7741    }
 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) =>
 5947        CompareConfigurationKeys(ConfigurationKey, other.ConfigurationKey);
 48
 49    internal static int CompareConfigurationKeys(
 50        GridConfigurationKey left,
 51        GridConfigurationKey right)
 52    {
 5953        int value = left.BoundsMin.X.CompareTo(right.BoundsMin.X);
 9454        if (value != 0) return value;
 2455        value = left.BoundsMin.Y.CompareTo(right.BoundsMin.Y);
 2656        if (value != 0) return value;
 2257        value = left.BoundsMin.Z.CompareTo(right.BoundsMin.Z);
 2458        if (value != 0) return value;
 2059        value = left.BoundsMax.X.CompareTo(right.BoundsMax.X);
 2260        if (value != 0) return value;
 1861        value = left.BoundsMax.Y.CompareTo(right.BoundsMax.Y);
 2062        if (value != 0) return value;
 1663        value = left.BoundsMax.Z.CompareTo(right.BoundsMax.Z);
 1864        if (value != 0) return value;
 1465        value = left.TopologyKind.CompareTo(right.TopologyKind);
 1666        if (value != 0) return value;
 1267        value = left.TopologyMetrics.CellRadius.CompareTo(right.TopologyMetrics.CellRadius);
 1468        if (value != 0) return value;
 1069        value = left.TopologyMetrics.CellWidth.CompareTo(right.TopologyMetrics.CellWidth);
 1270        if (value != 0) return value;
 871        value = left.TopologyMetrics.LayerHeight.CompareTo(right.TopologyMetrics.LayerHeight);
 1072        if (value != 0) return value;
 673        value = left.TopologyMetrics.CellLength.CompareTo(right.TopologyMetrics.CellLength);
 674        return value != 0
 675            ? value
 676            : left.TopologyMetrics.HexOrientation.CompareTo(right.TopologyMetrics.HexOrientation);
 77    }
 78}