Table of Contents

Struct SwiftGenerationalBucketState<T>

Namespace
SwiftCollections
Assembly
SwiftCollections.dll

Represents the immutable state of a generational bucket, including item storage, allocation status, generation tracking, and free index management.

[MemoryPackable(GenerateType.Object)]
public readonly struct SwiftGenerationalBucketState<T> : IMemoryPackable<SwiftGenerationalBucketState<T>>, IMemoryPackFormatterRegister

Type Parameters

T

The type of elements stored in the bucket.

Implements
IMemoryPackable<SwiftGenerationalBucketState<T>>
IMemoryPackFormatterRegister
Inherited Members

Remarks

This struct is typically used to capture or transfer the complete state of a generational bucket for serialization, persistence, or inspection purposes. All arrays are expected to be of the same length, and the struct is designed for efficient value-type usage. The state is read-only and does not provide mutation operations.

Constructors

SwiftGenerationalBucketState(T[], bool[], uint[], int[], int)

Initializes a new instance of the SwiftGenerationalBucketState class with the specified items, allocation states, generation counters, free indices, and peak index.

[JsonConstructor]
[MemoryPackConstructor]
public SwiftGenerationalBucketState(T[] items, bool[] allocated, uint[] generations, int[] freeIndices, int peak)

Parameters

items T[]

The array of items to be managed by the bucket. Cannot be null; an empty array is used if null is provided.

allocated bool[]

An array indicating which slots in the bucket are currently allocated. Each element corresponds to an item in the items array. Cannot be null; an empty array is used if null is provided.

generations uint[]

An array of generation counters for each slot in the bucket. Used to track the version or state of each item. Cannot be null; an empty array is used if null is provided.

freeIndices int[]

An array of indices representing the free slots available for allocation. Cannot be null; an empty array is used if null is provided.

peak int

The highest index that has been allocated in the bucket. Must be greater than or equal to zero.

Fields

Allocated

Indicates which items in the collection are currently allocated.

[JsonInclude]
[MemoryPackInclude]
public readonly bool[] Allocated

Field Value

bool[]

FreeIndices

Gets the collection of indices that are currently available for allocation.

[JsonInclude]
[MemoryPackInclude]
public readonly int[] FreeIndices

Field Value

int[]

Generations

Gets the collection of generation values associated with this instance.

[JsonInclude]
[MemoryPackInclude]
public readonly uint[] Generations

Field Value

uint[]

Items

Gets the array of items contained in the collection.

[JsonInclude]
[MemoryPackInclude]
public readonly T[] Items

Field Value

T[]

Peak

Gets the peak value recorded during the measurement period.

[JsonInclude]
[MemoryPackInclude]
public readonly int Peak

Field Value

int