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