Table of Contents

Struct InstanceCapacityHeap

Namespace
FishMMO.Server.Core.Collections
Assembly
FishMMO.Server.dll

A max-heap of scene instances, keyed by scene row ID, ordered by remaining capacity. Used for O(log N) fallback instance selection in open-world routing.

The root always holds the instance with the most remaining capacity. TryAssignFromTop(out long) peeks the root, decrements its capacity, and re-heapifies — yielding O(log N) per assignment instead of O(N) linear scan. If the root reaches zero capacity it is removed automatically.

public struct InstanceCapacityHeap
Inherited Members

Constructors

InstanceCapacityHeap(int)

Creates a new heap with pre-allocated backing storage.

public InstanceCapacityHeap(int capacity)

Parameters

capacity int

Initial backing array size (avoids resizing when known).

Properties

Count

Number of entries currently in the heap.

public int Count { get; }

Property Value

int

Methods

Push(long, int)

Pushes an instance (identified by its scene row ID) with its remaining capacity onto the heap. O(log N).

public void Push(long handle, int remainingCapacity)

Parameters

handle long
remainingCapacity int

TryAssignFromTop(out long)

Assigns the caller to the instance with the most remaining capacity. Decrements that instance's capacity and re-heapifies. If the instance reaches zero capacity it is removed from the heap.

public bool TryAssignFromTop(out long handle)

Parameters

handle long

The assigned scene row ID, or 0 if the heap is empty.

Returns

bool

true if an instance was available; false if the heap is empty.