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
impl PriorityQueueData
Sourcepub fn peek(&self) -> Option<i64>
pub fn peek(&self) -> Option<i64>
Peek at the minimum (root) without removing it. Returns None
for an empty queue.
Sourcepub fn push(&mut self, value: i64)
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>>.
Sourcepub fn pop(&mut self) -> Option<i64>
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.
Sourcepub fn to_vec(&self) -> Vec<i64>
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.
Sourcepub fn to_sorted_vec(&self) -> Vec<i64>
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.