| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace SwiftCollections.Query; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents an integer cell coordinate in a spatial hash grid. |
| | | 7 | | /// </summary> |
| | | 8 | | public readonly struct SwiftSpatialHashCellIndex : IEquatable<SwiftSpatialHashCellIndex> |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Initializes a new instance of the <see cref="SwiftSpatialHashCellIndex"/> struct. |
| | | 12 | | /// </summary> |
| | | 13 | | public SwiftSpatialHashCellIndex(int x, int y, int z) |
| | | 14 | | { |
| | 905 | 15 | | X = x; |
| | 905 | 16 | | Y = y; |
| | 905 | 17 | | Z = z; |
| | 905 | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Gets the X-axis cell coordinate. |
| | | 22 | | /// </summary> |
| | 1946 | 23 | | public int X { get; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets the Y-axis cell coordinate. |
| | | 27 | | /// </summary> |
| | 2194 | 28 | | public int Y { get; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets the Z-axis cell coordinate. |
| | | 32 | | /// </summary> |
| | 2978 | 33 | | public int Z { get; } |
| | | 34 | | |
| | | 35 | | /// <inheritdoc /> |
| | | 36 | | public bool Equals(SwiftSpatialHashCellIndex other) |
| | | 37 | | { |
| | 217 | 38 | | return X == other.X && Y == other.Y && Z == other.Z; |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <inheritdoc /> |
| | 2 | 42 | | public override bool Equals(object? obj) => obj is SwiftSpatialHashCellIndex other && Equals(other); |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Determines whether two SwiftSpatialHashCellIndex instances are equal. |
| | | 46 | | /// </summary> |
| | 2 | 47 | | public static bool operator ==(SwiftSpatialHashCellIndex left, SwiftSpatialHashCellIndex right) => left.Equals(right |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Determines whether two SwiftSpatialHashCellIndex instances are not equal. |
| | | 51 | | /// </summary> |
| | 1 | 52 | | public static bool operator !=(SwiftSpatialHashCellIndex left, SwiftSpatialHashCellIndex right) => !left.Equals(righ |
| | | 53 | | |
| | | 54 | | /// <inheritdoc /> |
| | 1245 | 55 | | public override int GetHashCode() => HashCode.Combine(X, Y, Z); |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Returns a string that represents the current object in the format "(X, Y, Z)". |
| | | 59 | | /// </summary> |
| | | 60 | | /// <remarks> |
| | | 61 | | /// This method is useful for debugging or logging purposes to quickly view the values of the |
| | | 62 | | /// object's coordinates. |
| | | 63 | | /// </remarks> |
| | | 64 | | /// <returns>A string representation of the object, showing the values of X, Y, and Z in parentheses and separated b |
| | 1 | 65 | | public override string ToString() => $"({X}, {Y}, {Z})"; |
| | | 66 | | } |