< Summary

Information
Class: Trailblazer.Pathing.NavigationWorkBudget
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Query/NavigationWorkBudget.cs
Line coverage
100%
Covered lines: 47
Uncovered lines: 0
Coverable lines: 47
Total lines: 131
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%
Equals(...)100%2020100%
Equals(...)100%22100%
GetHashCode()100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Query/NavigationWorkBudget.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationWorkBudget.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 finite deterministic work limits shared by a complete navigation query.
 15/// </summary>
 16public readonly struct NavigationWorkBudget : IEquatable<NavigationWorkBudget>
 17{
 18    /// <summary>Gets the maximum number of address or lookup probes.</summary>
 19    public int MaxLookupProbes { get; }
 20
 21    /// <summary>Gets the maximum number of endpoint candidates examined.</summary>
 22    public int MaxEndpointCandidates { get; }
 23
 24    /// <summary>Gets the maximum number of graph nodes expanded.</summary>
 25    public int MaxExpandedNodes { get; }
 26
 27    /// <summary>Gets the maximum number of graph edges evaluated.</summary>
 28    public int MaxEvaluatedEdges { get; }
 29
 30    /// <summary>Gets the maximum number of connection witness or polyline legs evaluated.</summary>
 31    public int MaxConnectionLegs { get; }
 32
 33    /// <summary>Gets the maximum number of transition candidates examined.</summary>
 34    public int MaxTransitionCandidates { get; }
 35
 36    /// <summary>Gets the maximum number of transition pairs evaluated.</summary>
 37    public int MaxTransitionPairs { get; }
 38
 39    /// <summary>Gets the maximum number of staged or nested path legs attempted.</summary>
 40    public int MaxStagedLegAttempts { get; }
 41
 42    /// <summary>Gets the maximum number of navigation-ray trace intervals visited.</summary>
 43    public int MaxTraceIntervals { get; }
 44
 45    /// <summary>Gets the maximum number of covered-voxel intervals visited.</summary>
 46    public int MaxCoveredVoxelIntervals { get; }
 47
 48    /// <summary>Gets the maximum number of path-simplification rays evaluated.</summary>
 49    public int MaxSimplificationRays { get; }
 50
 51    /// <summary>
 52    /// Creates a finite navigation work budget. Zero disables the corresponding category of work.
 53    /// </summary>
 54    /// <exception cref="ArgumentOutOfRangeException">Thrown when any limit is negative.</exception>
 55    public NavigationWorkBudget(
 56        int maxLookupProbes,
 57        int maxEndpointCandidates,
 58        int maxExpandedNodes,
 59        int maxEvaluatedEdges,
 60        int maxConnectionLegs,
 61        int maxTransitionCandidates,
 62        int maxTransitionPairs,
 63        int maxStagedLegAttempts,
 64        int maxTraceIntervals,
 65        int maxCoveredVoxelIntervals,
 66        int maxSimplificationRays)
 67    {
 211368        SwiftThrowHelper.ThrowIfNegative(maxLookupProbes, nameof(maxLookupProbes));
 210869        SwiftThrowHelper.ThrowIfNegative(maxEndpointCandidates, nameof(maxEndpointCandidates));
 210770        SwiftThrowHelper.ThrowIfNegative(maxExpandedNodes, nameof(maxExpandedNodes));
 210671        SwiftThrowHelper.ThrowIfNegative(maxEvaluatedEdges, nameof(maxEvaluatedEdges));
 210572        SwiftThrowHelper.ThrowIfNegative(maxConnectionLegs, nameof(maxConnectionLegs));
 210473        SwiftThrowHelper.ThrowIfNegative(maxTransitionCandidates, nameof(maxTransitionCandidates));
 210374        SwiftThrowHelper.ThrowIfNegative(maxTransitionPairs, nameof(maxTransitionPairs));
 210275        SwiftThrowHelper.ThrowIfNegative(maxStagedLegAttempts, nameof(maxStagedLegAttempts));
 210176        SwiftThrowHelper.ThrowIfNegative(maxTraceIntervals, nameof(maxTraceIntervals));
 210077        SwiftThrowHelper.ThrowIfNegative(maxCoveredVoxelIntervals, nameof(maxCoveredVoxelIntervals));
 209978        SwiftThrowHelper.ThrowIfNegative(maxSimplificationRays, nameof(maxSimplificationRays));
 79
 209880        MaxLookupProbes = maxLookupProbes;
 209881        MaxEndpointCandidates = maxEndpointCandidates;
 209882        MaxExpandedNodes = maxExpandedNodes;
 209883        MaxEvaluatedEdges = maxEvaluatedEdges;
 209884        MaxConnectionLegs = maxConnectionLegs;
 209885        MaxTransitionCandidates = maxTransitionCandidates;
 209886        MaxTransitionPairs = maxTransitionPairs;
 209887        MaxStagedLegAttempts = maxStagedLegAttempts;
 209888        MaxTraceIntervals = maxTraceIntervals;
 209889        MaxCoveredVoxelIntervals = maxCoveredVoxelIntervals;
 209890        MaxSimplificationRays = maxSimplificationRays;
 209891    }
 92
 93    /// <inheritdoc/>
 94    public bool Equals(NavigationWorkBudget other) =>
 271695        MaxLookupProbes == other.MaxLookupProbes
 271696        && MaxEndpointCandidates == other.MaxEndpointCandidates
 271697        && MaxExpandedNodes == other.MaxExpandedNodes
 271698        && MaxEvaluatedEdges == other.MaxEvaluatedEdges
 271699        && MaxConnectionLegs == other.MaxConnectionLegs
 2716100        && MaxTransitionCandidates == other.MaxTransitionCandidates
 2716101        && MaxTransitionPairs == other.MaxTransitionPairs
 2716102        && MaxStagedLegAttempts == other.MaxStagedLegAttempts
 2716103        && MaxTraceIntervals == other.MaxTraceIntervals
 2716104        && MaxCoveredVoxelIntervals == other.MaxCoveredVoxelIntervals
 2716105        && MaxSimplificationRays == other.MaxSimplificationRays;
 106
 107    /// <inheritdoc/>
 207108    public override bool Equals(object? obj) => obj is NavigationWorkBudget other && Equals(other);
 109
 110    /// <inheritdoc/>
 111    public override int GetHashCode()
 112    {
 3372113        int hash = SwiftHashTools.CombineHashCodes(MaxLookupProbes, MaxEndpointCandidates);
 3372114        hash = SwiftHashTools.CombineHashCodes(hash, MaxExpandedNodes);
 3372115        hash = SwiftHashTools.CombineHashCodes(hash, MaxEvaluatedEdges);
 3372116        hash = SwiftHashTools.CombineHashCodes(hash, MaxConnectionLegs);
 3372117        hash = SwiftHashTools.CombineHashCodes(hash, MaxTransitionCandidates);
 3372118        hash = SwiftHashTools.CombineHashCodes(hash, MaxTransitionPairs);
 3372119        hash = SwiftHashTools.CombineHashCodes(hash, MaxStagedLegAttempts);
 3372120        hash = SwiftHashTools.CombineHashCodes(hash, MaxTraceIntervals);
 3372121        hash = SwiftHashTools.CombineHashCodes(hash, MaxCoveredVoxelIntervals);
 3372122        return SwiftHashTools.CombineHashCodes(hash, MaxSimplificationRays);
 123    }
 124
 125    /// <summary>Returns whether two budgets have exactly equal limits.</summary>
 2498126    public static bool operator ==(NavigationWorkBudget left, NavigationWorkBudget right) => left.Equals(right);
 127
 128    /// <summary>Returns whether two budgets differ.</summary>
 1129    public static bool operator !=(NavigationWorkBudget left, NavigationWorkBudget right) => !left.Equals(right);
 130
 131}