< Summary

Information
Class: Trailblazer.Pathing.GuideSampleWorkBudget
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Query/GuideSampleWorkBudget.cs
Line coverage
100%
Covered lines: 31
Uncovered lines: 0
Coverable lines: 31
Total lines: 98
Line coverage: 100%
Branch coverage
100%
Covered branches: 14
Total branches: 14
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%1212100%
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/GuideSampleWorkBudget.cs

#LineLine coverage
 1//=======================================================================
 2// GuideSampleWorkBudget.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 for one guide sampling operation.
 15/// </summary>
 16public readonly struct GuideSampleWorkBudget : IEquatable<GuideSampleWorkBudget>
 17{
 18    /// <summary>Gets the maximum number of current-node lookup probes.</summary>
 19    public int MaxCurrentNodeLookupProbes { get; }
 20
 21    /// <summary>Gets the maximum number of cursor-leg scans.</summary>
 22    public int MaxCursorLegScans { get; }
 23
 24    /// <summary>Gets the maximum number of cursor rebases.</summary>
 25    public int MaxCursorRebases { get; }
 26
 27    /// <summary>Gets the maximum number of portal checks.</summary>
 28    public int MaxPortalChecks { get; }
 29
 30    /// <summary>Gets the maximum number of prism checks.</summary>
 31    public int MaxPrismChecks { get; }
 32
 33    /// <summary>Gets the maximum number of trace intervals visited.</summary>
 34    public int MaxTraceIntervals { get; }
 35
 36    /// <summary>Gets the maximum number of local recovery attempts.</summary>
 37    public int MaxLocalRecoveryAttempts { get; }
 38
 39    /// <summary>
 40    /// Creates a finite guide sample work budget. Zero disables the corresponding category of work.
 41    /// </summary>
 42    /// <exception cref="ArgumentOutOfRangeException">Thrown when any limit is negative.</exception>
 43    public GuideSampleWorkBudget(
 44        int maxCurrentNodeLookupProbes,
 45        int maxCursorLegScans,
 46        int maxCursorRebases,
 47        int maxPortalChecks,
 48        int maxPrismChecks,
 49        int maxTraceIntervals,
 50        int maxLocalRecoveryAttempts)
 51    {
 142852        SwiftThrowHelper.ThrowIfNegative(maxCurrentNodeLookupProbes, nameof(maxCurrentNodeLookupProbes));
 142753        SwiftThrowHelper.ThrowIfNegative(maxCursorLegScans, nameof(maxCursorLegScans));
 142654        SwiftThrowHelper.ThrowIfNegative(maxCursorRebases, nameof(maxCursorRebases));
 142555        SwiftThrowHelper.ThrowIfNegative(maxPortalChecks, nameof(maxPortalChecks));
 142456        SwiftThrowHelper.ThrowIfNegative(maxPrismChecks, nameof(maxPrismChecks));
 142357        SwiftThrowHelper.ThrowIfNegative(maxTraceIntervals, nameof(maxTraceIntervals));
 142258        SwiftThrowHelper.ThrowIfNegative(maxLocalRecoveryAttempts, nameof(maxLocalRecoveryAttempts));
 59
 142160        MaxCurrentNodeLookupProbes = maxCurrentNodeLookupProbes;
 142161        MaxCursorLegScans = maxCursorLegScans;
 142162        MaxCursorRebases = maxCursorRebases;
 142163        MaxPortalChecks = maxPortalChecks;
 142164        MaxPrismChecks = maxPrismChecks;
 142165        MaxTraceIntervals = maxTraceIntervals;
 142166        MaxLocalRecoveryAttempts = maxLocalRecoveryAttempts;
 142167    }
 68
 69    /// <inheritdoc/>
 70    public bool Equals(GuideSampleWorkBudget other) =>
 1471        MaxCurrentNodeLookupProbes == other.MaxCurrentNodeLookupProbes
 1472        && MaxCursorLegScans == other.MaxCursorLegScans
 1473        && MaxCursorRebases == other.MaxCursorRebases
 1474        && MaxPortalChecks == other.MaxPortalChecks
 1475        && MaxPrismChecks == other.MaxPrismChecks
 1476        && MaxTraceIntervals == other.MaxTraceIntervals
 1477        && MaxLocalRecoveryAttempts == other.MaxLocalRecoveryAttempts;
 78
 79    /// <inheritdoc/>
 680    public override bool Equals(object? obj) => obj is GuideSampleWorkBudget other && Equals(other);
 81
 82    /// <inheritdoc/>
 83    public override int GetHashCode()
 84    {
 285        int hash = SwiftHashTools.CombineHashCodes(MaxCurrentNodeLookupProbes, MaxCursorLegScans);
 286        hash = SwiftHashTools.CombineHashCodes(hash, MaxCursorRebases);
 287        hash = SwiftHashTools.CombineHashCodes(hash, MaxPortalChecks);
 288        hash = SwiftHashTools.CombineHashCodes(hash, MaxPrismChecks);
 289        hash = SwiftHashTools.CombineHashCodes(hash, MaxTraceIntervals);
 290        return SwiftHashTools.CombineHashCodes(hash, MaxLocalRecoveryAttempts);
 91    }
 92
 93    /// <summary>Returns whether two budgets have exactly equal limits.</summary>
 194    public static bool operator ==(GuideSampleWorkBudget left, GuideSampleWorkBudget right) => left.Equals(right);
 95
 96    /// <summary>Returns whether two budgets differ.</summary>
 197    public static bool operator !=(GuideSampleWorkBudget left, GuideSampleWorkBudget right) => !left.Equals(right);
 98}