< Summary

Information
Class: SwiftCollections.Query.SwiftOctreeOptions
Assembly: SwiftCollections
File(s): /home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Query/Octree/SwiftOctreeOptions.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 82
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
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%
.ctor(...)100%44100%
Equals(...)100%44100%
Equals(...)100%22100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%
GetHashCode()100%11100%

File(s)

/home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Query/Octree/SwiftOctreeOptions.cs

#LineLine coverage
 1//=======================================================================
 2// SwiftOctreeOptions.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;
 9
 10namespace SwiftCollections.Query;
 11
 12/// <summary>
 13/// Controls node subdivision behavior for <see cref="SwiftOctree{TKey, TVolume}"/>.
 14/// </summary>
 15public readonly struct SwiftOctreeOptions : IEquatable<SwiftOctreeOptions>
 16{
 17    /// <summary>
 18    /// Initializes a new instance of the <see cref="SwiftOctreeOptions"/> struct.
 19    /// </summary>
 20    /// <param name="maxDepth">The maximum child depth allowed below the root node.</param>
 21    /// <param name="nodeCapacity">The maximum number of entries a node should hold before attempting to split.</param>
 22    public SwiftOctreeOptions(int maxDepth, int nodeCapacity)
 9023        : this(maxDepth, nodeCapacity, true) { }
 24
 25    /// <summary>
 26    /// Initializes a new instance of the <see cref="SwiftOctreeOptions"/> struct.
 27    /// </summary>
 28    /// <param name="maxDepth">The maximum child depth allowed below the root node.</param>
 29    /// <param name="nodeCapacity">The maximum number of entries a node should hold before attempting to split.</param>
 30    /// <param name="enableMergeOnRemove">Whether empty child regions should collapse back into their parent after remov
 31    public SwiftOctreeOptions(int maxDepth, int nodeCapacity, bool enableMergeOnRemove)
 32    {
 5433        if (maxDepth < 0)
 134            throw new ArgumentOutOfRangeException(nameof(maxDepth), maxDepth, "Maximum depth must be zero or greater.");
 35
 5336        if (nodeCapacity <= 0)
 137            throw new ArgumentOutOfRangeException(nameof(nodeCapacity), nodeCapacity, "Node capacity must be greater tha
 38
 5239        MaxDepth = maxDepth;
 5240        NodeCapacity = nodeCapacity;
 5241        EnableMergeOnRemove = enableMergeOnRemove;
 5242    }
 43
 44    /// <summary>
 45    /// Gets the maximum child depth allowed below the root node.
 46    /// </summary>
 47    public int MaxDepth { get; }
 48
 49    /// <summary>
 50    /// Gets the preferred number of entries per node before subdivision is attempted.
 51    /// </summary>
 52    public int NodeCapacity { get; }
 53
 54    /// <summary>
 55    /// Gets a value indicating whether nodes should merge after removals leave sparse children.
 56    /// </summary>
 57    public bool EnableMergeOnRemove { get; }
 58
 59    /// <inheritdoc />
 60    public bool Equals(SwiftOctreeOptions other)
 61    {
 762        return MaxDepth == other.MaxDepth &&
 763               NodeCapacity == other.NodeCapacity &&
 764               EnableMergeOnRemove == other.EnableMergeOnRemove;
 65    }
 66
 67    /// <inheritdoc />
 268    public override bool Equals(object? obj) => obj is SwiftOctreeOptions other && Equals(other);
 69
 70    /// <summary>
 71    /// Determines whether two SwiftOctreeOptions instances are equal.
 72    /// </summary>
 273    public static bool operator ==(SwiftOctreeOptions left, SwiftOctreeOptions right) => left.Equals(right);
 74
 75    /// <summary>
 76    /// Determines whether two SwiftOctreeOptions instances are not equal.
 77    /// </summary>
 178    public static bool operator !=(SwiftOctreeOptions left, SwiftOctreeOptions right) => !(left == right);
 79
 80    /// <inheritdoc />
 281    public override int GetHashCode() => HashCode.Combine(MaxDepth, NodeCapacity, EnableMergeOnRemove);
 82}