< Summary

Information
Class: GridForge.OccupantTicket
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Support/OccupantTicket.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 57
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
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%
get_IsValid()100%22100%
Equals(...)100%22100%
Equals(...)100%22100%
GetHashCode()100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Support/OccupantTicket.cs

#LineLine coverage
 1//=======================================================================
 2// OccupantTicket.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 GridForge;
 12
 13/// <summary>
 14/// Identifies one occupant registration in a scan-cell bucket.
 15/// </summary>
 16public readonly struct OccupantTicket : IEquatable<OccupantTicket>
 17{
 18    /// <summary>
 19    /// The O(1) lookup slot within the voxel's occupant bucket.
 20    /// </summary>
 21    public int Slot { get; }
 22
 23    /// <summary>
 24    /// The process-unique generation assigned to this registration lifetime.
 25    /// </summary>
 26    public long Generation { get; }
 27
 28    internal OccupantTicket(int slot, long generation)
 29    {
 70430        Slot = slot;
 70431        Generation = generation;
 70432    }
 33
 34    /// <summary>
 35    /// Indicates whether this ticket identifies an allocated occupant registration.
 36    /// </summary>
 838337    public bool IsValid => Slot >= 0 && Generation > 0;
 38
 39    /// <inheritdoc />
 1740    public bool Equals(OccupantTicket other) => Slot == other.Slot && Generation == other.Generation;
 41
 42    /// <inheritdoc />
 243    public override bool Equals(object? obj) => obj is OccupantTicket other && Equals(other);
 44
 45    /// <inheritdoc />
 246    public override int GetHashCode() => SwiftHashTools.CombineHashCodes(Slot, Generation.GetHashCode());
 47
 48    /// <summary>
 49    /// Compares two occupant tickets for equality.
 50    /// </summary>
 151    public static bool operator ==(OccupantTicket left, OccupantTicket right) => left.Equals(right);
 52
 53    /// <summary>
 54    /// Compares two occupant tickets for inequality.
 55    /// </summary>
 156    public static bool operator !=(OccupantTicket left, OccupantTicket right) => !left.Equals(right);
 57}