Skip to main content

PriorityQueueData

Struct PriorityQueueData 

Source
pub struct PriorityQueueData {
    pub heap: Arc<Vec<i64>>,
}
Expand description

PriorityQueue storage — i64-priority min-heap.

ADR-006 §2.7.18 / Q19 amendment (mirror of §2.7.15 HashSet precedent for the cardinality-amendment shape). Storage is a binary min-heap laid out in a single Vec<i64> over an Arc<TypedBuffer<i64>> so the buffer-Arc pattern matches the rest of the typed-Arc heap family (clone-on-write via Arc::make_mut, single atomic refcount at slot drop).

i64-priority-only at landing (per the Wave 15 audit and the §2.7.18 Q19 ruling). Heterogeneous-payload priority queues (TypedObject-payload, payload-with-comparator-closure) are explicitly out-of-scope; the playbook called out the i64-priority- only design as the simpler valid path, and the smoke target (pq.push(3); pq.push(1); pq.push(2); pq.pop() == 1) is exercised end-to-end on this shape. A typed-payload rebuild (PriorityQueue <T, K> with key-extractor and arbitrary T payloads) is a future Phase-2c amendment with measurement.

The heap invariant is “min-heap”: the minimum priority sits at index 0 (peek() / pop() return it). Standard sift-up-on-push / sift-down-on-pop maintenance, O(log n) per push/pop.

Fields§

§heap: Arc<Vec<i64>>

Heap-ordered i64 priorities. Index 0 is the current min. Backed by an Arc<Vec<i64>> so a HeapValue clone is a single atomic refcount bump and Arc::make_mut is the canonical clone-on-write entry per the W13-hashmap-mutation precedent.

Storage shape: Arc<Vec<i64>> post-V3-S5 ckpt-5-prime²a (Migration shape (a) per supervisor 2026-05-15 ratification — TypedBuffer<T> wrapper layer retired wholesale at ckpt-4; Arc<Vec<T>> is the smallest delta preserving Arc::make_mut clone-on-write semantics).

Implementations§

Source§

impl PriorityQueueData

Source

pub fn new() -> Self

Build an empty PriorityQueueData with no entries.

Source

pub fn len(&self) -> usize

Number of entries.

Source

pub fn is_empty(&self) -> bool

Whether the queue is empty.

Source

pub fn peek(&self) -> Option<i64>

Peek at the minimum (root) without removing it. Returns None for an empty queue.

Source

pub fn push(&mut self, value: i64)

Push a value, restoring the min-heap invariant via sift-up. Mirror of W13-hashmap-mutation insert: Arc::make_mut clone-on-write over the inner Arc<Vec<i64>>.

Source

pub fn pop(&mut self) -> Option<i64>

Pop the minimum value, restoring the min-heap invariant via sift-down. Returns None for an empty queue. Mirror of W13-hashmap-mutation remove: Arc::make_mut clone-on-write.

Source

pub fn to_vec(&self) -> Vec<i64>

Return the heap contents as a flat Vec<i64> in heap-array order (NOT sorted). Used for the toArray method’s Vec<int> projection; for the sorted form see to_sorted_vec.

Source

pub fn to_sorted_vec(&self) -> Vec<i64>

Return the heap contents as a sorted Vec<i64> (ascending — pop-order). Used for the toSortedArray method.

Trait Implementations§

Source§

impl Clone for PriorityQueueData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PriorityQueueData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PriorityQueueData

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,