Class ScyllaStackDOTS<T>.Builder
Fluent builder for configuring and constructing ScyllaStackDOTS<T> instances.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaStackDOTS<T>.Builder
Remarks
The builder defaults to a capacity of 4 and Unity.Collections.NativeArrayOptions.UninitializedMemory. WithAllocator(Allocator) is mandatory and must be called before Build() or BuildConcrete().
Unlike the managed ScyllaStack<T>.Builder, this builder has no
Synchronized option because ScyllaStackDOTS<T> does not
provide a synchronized wrapper. Build() and BuildConcrete()
are therefore functionally equivalent and both return a
ScyllaStackDOTS<T> directly.
Methods
Build()
Builds and returns the configured ScyllaStackDOTS<T> instance.
Declaration
public ScyllaStackDOTS<T> Build()
Returns
| Type | Description |
|---|---|
| ScyllaStackDOTS<T> | A fully configured ScyllaStackDOTS<T> ready for use. |
Remarks
Because ScyllaStackDOTS<T> does not provide a synchronized wrapper, this method always returns the concrete struct type directly (unlike the managed Build() which may return a ScyllaStack<T>.SynchronizedScyllaStack). This method is functionally identical to BuildConcrete() and exists for API consistency with other Scylla collection builders.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when WithAllocator(Allocator) has not been called before this method. |
BuildConcrete()
Builds and returns the configured ScyllaStackDOTS<T> instance.
Functionally identical to Build(); provided for API consistency with
other Scylla collection builders that have distinct Build and BuildConcrete
methods (where Build may return a synchronized wrapper).
Declaration
public ScyllaStackDOTS<T> BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaStackDOTS<T> | A fully configured ScyllaStackDOTS<T> ready for use. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when WithAllocator(Allocator) has not been called before this method. |
OverwriteOnFull(bool)
Configures the stack to drop the oldest (bottom) element when a push is attempted
on a full stack, rather than returning false.
Declaration
public ScyllaStackDOTS<T>.Builder OverwriteOnFull(bool value = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value |
|
Returns
| Type | Description |
|---|---|
| ScyllaStackDOTS<T>.Builder | This builder instance, enabling method chaining. |
Remarks
When enabled, pushing onto a full stack invokes an O(n) shift of all existing elements toward index 0, then writes the new item at the top. The stack size remains constant at capacity. If this O(n) cost is unacceptable, consider ScyllaRingBufferDOTS<T>, which achieves the same logical behavior in O(1) using a circular index.
WithAllocator(Allocator)
Sets the Unity memory allocator used for the internal Unity.Collections.NativeArray<T>. This method must be called before Build() or BuildConcrete().
Declaration
public ScyllaStackDOTS<T>.Builder WithAllocator(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | The memory allocator for the native buffer. Must not be Unity.Collections.Allocator.None. |
Returns
| Type | Description |
|---|---|
| ScyllaStackDOTS<T>.Builder | This builder instance, enabling method chaining. |
Remarks
Choose an allocator based on the expected lifetime of the stack:
- Unity.Collections.Allocator.Persistent - for stacks that live across multiple frames or for the duration of a scene.
- Unity.Collections.Allocator.TempJob - for stacks that are created, used within a job, and disposed within the same frame.
- Unity.Collections.Allocator.Temp - for stacks used only within a single frame on the main thread (must be disposed before the frame ends).
Unity.Collections.Allocator.None is explicitly forbidden and will throw an ArgumentException both here and during Build().
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
WithCapacity(int)
Sets the fixed capacity of the stack.
Declaration
public ScyllaStackDOTS<T>.Builder WithCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The total number of elements the stack can hold. Must be greater than or equal to 0; negative values are rejected with an ArgumentOutOfRangeException. A value of 0 is accepted and will result in a capacity of 1 after clamping. |
Returns
| Type | Description |
|---|---|
| ScyllaStackDOTS<T>.Builder | This builder instance, enabling method chaining. |
Remarks
The capacity is rounded up to a minimum of 1 during construction if a value of 0 is provided. The builder itself rejects negative values.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
WithNativeArrayOptions(NativeArrayOptions)
Sets the Unity.Collections.NativeArray<T> initialization options used when allocating the backing buffer.
Declaration
public ScyllaStackDOTS<T>.Builder WithNativeArrayOptions(NativeArrayOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArrayOptions | options | The native array options. Defaults to Unity.Collections.NativeArrayOptions.UninitializedMemory for maximum allocation speed. Pass Unity.Collections.NativeArrayOptions.ClearMemory to zero-initialize the buffer, which is useful when the memory must not contain stale data. |
Returns
| Type | Description |
|---|---|
| ScyllaStackDOTS<T>.Builder | This builder instance, enabling method chaining. |