< Summary

Information
Class: SwiftCollections.Query.SwiftSpatialHashCellIndex
Assembly: SwiftCollections
File(s): /home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Query/SpatialHash/SwiftSpatialHashCellIndex.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 74
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%
Equals(...)100%44100%
Equals(...)100%22100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%
GetHashCode()100%11100%
ToString()100%11100%

File(s)

/home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Query/SpatialHash/SwiftSpatialHashCellIndex.cs

#LineLine coverage
 1//=======================================================================
 2// SwiftSpatialHashCellIndex.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 SwiftCollections.Query;
 12
 13/// <summary>
 14/// Represents an integer cell coordinate in a spatial hash grid.
 15/// </summary>
 16public readonly struct SwiftSpatialHashCellIndex : IEquatable<SwiftSpatialHashCellIndex>
 17{
 18    /// <summary>
 19    /// Initializes a new instance of the <see cref="SwiftSpatialHashCellIndex"/> struct.
 20    /// </summary>
 21    public SwiftSpatialHashCellIndex(int x, int y, int z)
 22    {
 112623        X = x;
 112624        Y = y;
 112625        Z = z;
 112626    }
 27
 28    /// <summary>
 29    /// Gets the X-axis cell coordinate.
 30    /// </summary>
 31    public int X { get; }
 32
 33    /// <summary>
 34    /// Gets the Y-axis cell coordinate.
 35    /// </summary>
 36    public int Y { get; }
 37
 38    /// <summary>
 39    /// Gets the Z-axis cell coordinate.
 40    /// </summary>
 41    public int Z { get; }
 42
 43    /// <inheritdoc />
 44    public bool Equals(SwiftSpatialHashCellIndex other)
 45    {
 25646        return X == other.X && Y == other.Y && Z == other.Z;
 47    }
 48
 49    /// <inheritdoc />
 250    public override bool Equals(object? obj) => obj is SwiftSpatialHashCellIndex other && Equals(other);
 51
 52    /// <summary>
 53    /// Determines whether two SwiftSpatialHashCellIndex instances are equal.
 54    /// </summary>
 255    public static bool operator ==(SwiftSpatialHashCellIndex left, SwiftSpatialHashCellIndex right) => left.Equals(right
 56
 57    /// <summary>
 58    /// Determines whether two SwiftSpatialHashCellIndex instances are not equal.
 59    /// </summary>
 160    public static bool operator !=(SwiftSpatialHashCellIndex left, SwiftSpatialHashCellIndex right) => !left.Equals(righ
 61
 62    /// <inheritdoc />
 157863    public override int GetHashCode() => SwiftHashTools.CombineHashCodes(X, Y, Z);
 64
 65    /// <summary>
 66    /// Returns a string that represents the current object in the format "(X, Y, Z)".
 67    /// </summary>
 68    /// <remarks>
 69    /// This method is useful for debugging or logging purposes to quickly view the values of the
 70    /// object's coordinates.
 71    /// </remarks>
 72    /// <returns>A string representation of the object, showing the values of X, Y, and Z in parentheses and separated b
 173    public override string ToString() => $"({X}, {Y}, {Z})";
 74}