Class ScyllaKDTree3.Builder
Fluent builder for configuring and constructing ScyllaKDTree3 instances.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaKDTree3.Builder
Methods
Build()
Builds and returns the configured ScyllaKDTree3 instance.
Declaration
public ScyllaKDTree3 Build()
Returns
| Type | Description |
|---|---|
| ScyllaKDTree3 | The configured ScyllaKDTree3 instance |
Remarks
Validates that WithAllocator(Allocator) has been called before constructing the KD-tree. Since ScyllaKDTree3 doesn't have a synchronized wrapper, this method returns the concrete type directly.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when allocator has not been set via WithAllocator() |
BuildConcrete()
Builds and returns the concrete ScyllaKDTree3 instance. This method is functionally identical to Build() since ScyllaKDTree3 doesn't have a synchronized wrapper.
Declaration
public ScyllaKDTree3 BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaKDTree3 | The configured ScyllaKDTree3 instance |
Remarks
Validates that WithAllocator(Allocator) has been called before constructing the KD-tree. This method exists for API consistency with other collection builders, but returns the same type as Build().
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when allocator has not been set via WithAllocator() |
WithAllocator(Allocator)
Sets the memory allocator for native containers. This method must be called before Build() or BuildConcrete().
Declaration
public ScyllaKDTree3.Builder WithAllocator(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | Memory allocator for native containers (must not be Allocator.None) |
Returns
| Type | Description |
|---|---|
| ScyllaKDTree3.Builder | This builder instance for method chaining |
Remarks
Allocator Selection:
- Allocator.Persistent: Long-lived KD-tree (recommended for most game scenarios)
- Allocator.TempJob: KD-tree used within a single frame across jobs
- Allocator.Temp: Short-lived KD-tree used within a single frame (avoid for KD-tree due to size)
Validation:
Allocator.None is not allowed and will throw an ArgumentException.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when allocator is Allocator.None |
WithNodeCapacity(int)
Sets the initial capacity for node storage.
Declaration
public ScyllaKDTree3.Builder WithNodeCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial node capacity. Must be at least 0. If negative, will be clamped to 1 during construction. |
Returns
| Type | Description |
|---|---|
| ScyllaKDTree3.Builder | This builder instance for method chaining |
Remarks
This is a hint to reduce early allocations. The KD-tree will grow automatically if needed. For a complete binary tree, node capacity should be approximately equal to point capacity.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when capacity is negative |
WithPointCapacity(int)
Sets the initial capacity for point storage.
Declaration
public ScyllaKDTree3.Builder WithPointCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial point capacity. Must be at least 0. If negative, will be clamped to 1 during construction. |
Returns
| Type | Description |
|---|---|
| ScyllaKDTree3.Builder | This builder instance for method chaining |
Remarks
This is a hint to reduce early allocations. The KD-tree will grow automatically if needed. Set this to the number of points you expect to store.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when capacity is negative |