< Summary

Information
Class: Trailblazer.Pathing.MaintenanceWorkBudget
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Graph/MaintenanceWorkBudget.cs
Line coverage
100%
Covered lines: 59
Uncovered lines: 0
Coverable lines: 59
Total lines: 129
Line coverage: 100%
Branch coverage
100%
Covered branches: 16
Total branches: 16
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%
Equals(...)100%1414100%
Equals(...)100%22100%
GetHashCode()100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Graph/MaintenanceWorkBudget.cs

#LineLine coverage
 1//=======================================================================
 2// MaintenanceWorkBudget.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 SwiftCollections.Utility;
 10
 11namespace Trailblazer.Pathing;
 12
 13/// <summary>
 14/// Defines the finite deterministic work counters consumed at one graph-maintenance boundary.
 15/// </summary>
 16public readonly struct MaintenanceWorkBudget : IEquatable<MaintenanceWorkBudget>
 17{
 18    /// <summary>Creates an explicit positive maintenance budget.</summary>
 19    public MaintenanceWorkBudget(
 20        int maxConsumedEnvelopes,
 21        int maxBaselineAddresses,
 22        int maxOverlaySlots,
 23        int maxComponentNodes,
 24        int maxSeamCandidateProbes,
 25        int maxExplicitEdges,
 26        int maxDependencyEntries,
 27        int maxSurfaceComponentEdges = 65_536)
 28    {
 202729        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 202730            maxConsumedEnvelopes <= 0,
 202731            maxConsumedEnvelopes,
 202732            nameof(maxConsumedEnvelopes));
 202633        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 202634            maxBaselineAddresses <= 0,
 202635            maxBaselineAddresses,
 202636            nameof(maxBaselineAddresses));
 202537        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 202538            maxOverlaySlots <= 0,
 202539            maxOverlaySlots,
 202540            nameof(maxOverlaySlots));
 202441        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 202442            maxComponentNodes <= 0,
 202443            maxComponentNodes,
 202444            nameof(maxComponentNodes));
 202345        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 202346            maxSeamCandidateProbes <= 0,
 202347            maxSeamCandidateProbes,
 202348            nameof(maxSeamCandidateProbes));
 202249        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 202250            maxExplicitEdges <= 0,
 202251            maxExplicitEdges,
 202252            nameof(maxExplicitEdges));
 202153        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 202154            maxDependencyEntries <= 0,
 202155            maxDependencyEntries,
 202156            nameof(maxDependencyEntries));
 202057        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 202058            maxSurfaceComponentEdges <= 0,
 202059            maxSurfaceComponentEdges,
 202060            nameof(maxSurfaceComponentEdges));
 61
 201962        MaxConsumedEnvelopes = maxConsumedEnvelopes;
 201963        MaxBaselineAddresses = maxBaselineAddresses;
 201964        MaxOverlaySlots = maxOverlaySlots;
 201965        MaxComponentNodes = maxComponentNodes;
 201966        MaxSeamCandidateProbes = maxSeamCandidateProbes;
 201967        MaxExplicitEdges = maxExplicitEdges;
 201968        MaxDependencyEntries = maxDependencyEntries;
 201969        MaxSurfaceComponentEdges = maxSurfaceComponentEdges;
 201970    }
 71
 72    /// <summary>Gets the maximum detached GridForge envelopes consumed.</summary>
 73    public int MaxConsumedEnvelopes { get; }
 74
 75    /// <summary>Gets the maximum address-filtered baseline entries consumed.</summary>
 76    public int MaxBaselineAddresses { get; }
 77
 78    /// <summary>Gets the maximum semantic overlay slots processed.</summary>
 79    public int MaxOverlaySlots { get; }
 80
 81    /// <summary>Gets the maximum structural-component nodes processed.</summary>
 82    public int MaxComponentNodes { get; }
 83
 84    /// <summary>Gets the maximum automatic-seam pair, source-address, and target-address probes.</summary>
 85    public int MaxSeamCandidateProbes { get; }
 86
 87    /// <summary>Gets the maximum accepted explicit, seam, or transition edges processed.</summary>
 88    public int MaxExplicitEdges { get; }
 89
 90    /// <summary>Gets the maximum dependency-index entries processed.</summary>
 91    public int MaxDependencyEntries { get; }
 92
 93    /// <summary>Gets the maximum directed surface-edge candidates inspected by component work.</summary>
 94    public int MaxSurfaceComponentEdges { get; }
 95
 96    /// <inheritdoc/>
 97    public bool Equals(MaintenanceWorkBudget other) =>
 898        MaxConsumedEnvelopes == other.MaxConsumedEnvelopes
 899        && MaxBaselineAddresses == other.MaxBaselineAddresses
 8100        && MaxOverlaySlots == other.MaxOverlaySlots
 8101        && MaxComponentNodes == other.MaxComponentNodes
 8102        && MaxSeamCandidateProbes == other.MaxSeamCandidateProbes
 8103        && MaxExplicitEdges == other.MaxExplicitEdges
 8104        && MaxDependencyEntries == other.MaxDependencyEntries
 8105        && MaxSurfaceComponentEdges == other.MaxSurfaceComponentEdges;
 106
 107    /// <inheritdoc/>
 2108    public override bool Equals(object? obj) => obj is MaintenanceWorkBudget other && Equals(other);
 109
 110    /// <inheritdoc/>
 111    public override int GetHashCode()
 112    {
 5113        int hash = SwiftHashTools.CombineHashCodes(MaxConsumedEnvelopes, MaxBaselineAddresses);
 5114        hash = SwiftHashTools.CombineHashCodes(hash, MaxOverlaySlots);
 5115        hash = SwiftHashTools.CombineHashCodes(hash, MaxComponentNodes);
 5116        hash = SwiftHashTools.CombineHashCodes(hash, MaxSeamCandidateProbes);
 5117        hash = SwiftHashTools.CombineHashCodes(hash, MaxExplicitEdges);
 5118        hash = SwiftHashTools.CombineHashCodes(hash, MaxDependencyEntries);
 5119        return SwiftHashTools.CombineHashCodes(hash, MaxSurfaceComponentEdges);
 120    }
 121
 122    /// <summary>Tests two budgets for equality.</summary>
 123    public static bool operator ==(MaintenanceWorkBudget left, MaintenanceWorkBudget right) =>
 1124        left.Equals(right);
 125
 126    /// <summary>Tests two budgets for inequality.</summary>
 127    public static bool operator !=(MaintenanceWorkBudget left, MaintenanceWorkBudget right) =>
 1128        !left.Equals(right);
 129}