| | | 1 | | //======================================================================= |
| | | 2 | | // SwiftSpatialHashOptions.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 | | |
| | | 8 | | using System; |
| | | 9 | | |
| | | 10 | | namespace SwiftCollections.Query; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Controls neighborhood query behavior for <see cref="SwiftSpatialHash{TKey, TVolume}"/>. |
| | | 14 | | /// </summary> |
| | | 15 | | public readonly struct SwiftSpatialHashOptions : IEquatable<SwiftSpatialHashOptions> |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// The default options value. |
| | | 19 | | /// </summary> |
| | | 20 | | public static SwiftSpatialHashOptions Default { get; } = new SwiftSpatialHashOptions(1); |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Initializes a new instance of the <see cref="SwiftSpatialHashOptions"/> struct. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <param name="neighborhoodPadding">The number of additional cells to include around neighborhood queries.</param> |
| | | 26 | | public SwiftSpatialHashOptions(int neighborhoodPadding) |
| | | 27 | | { |
| | 7 | 28 | | if (neighborhoodPadding < 0) |
| | 1 | 29 | | throw new ArgumentOutOfRangeException(nameof(neighborhoodPadding), neighborhoodPadding, "Neighborhood paddin |
| | | 30 | | |
| | 6 | 31 | | NeighborhoodPadding = neighborhoodPadding; |
| | 6 | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Gets the number of extra cells queried beyond the mapped volume range when using neighborhood queries. |
| | | 36 | | /// </summary> |
| | | 37 | | public int NeighborhoodPadding { get; } |
| | | 38 | | |
| | | 39 | | /// <inheritdoc /> |
| | 5 | 40 | | public bool Equals(SwiftSpatialHashOptions other) => NeighborhoodPadding == other.NeighborhoodPadding; |
| | | 41 | | |
| | | 42 | | /// <inheritdoc /> |
| | 2 | 43 | | public override bool Equals(object? obj) => obj is SwiftSpatialHashOptions other && Equals(other); |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Determines whether two SwiftSpatialHashOptions instances are equal. |
| | | 47 | | /// </summary> |
| | 1 | 48 | | public static bool operator ==(SwiftSpatialHashOptions left, SwiftSpatialHashOptions right) => left.Equals(right); |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Determines whether two SwiftSpatialHashOptions instances are not equal. |
| | | 52 | | /// </summary> |
| | 1 | 53 | | public static bool operator !=(SwiftSpatialHashOptions left, SwiftSpatialHashOptions right) => !left.Equals(right); |
| | | 54 | | |
| | | 55 | | /// <inheritdoc /> |
| | 2 | 56 | | public override int GetHashCode() => NeighborhoodPadding; |
| | | 57 | | } |