collections: BankersQueue, a persistent queue with shared structure (C7) #199
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
BankersQueue<Item>: an implementation ofQueueas two cons lists (front, and rear reversed), O(1) amortisedenqueue/dequeue, with copies sharing structure (COLLECTIONS.md section 3.3 table).Acceptance criteria
public type BankersQueue<Item> with Queue<Item>, From<Iterate<Item>>;enqueue,dequeue,peek,length,iterate(front to back),clear,compact,Equals/HashasArrayQueue.ConsStack(#198); if it needs a shared private node type, it lands after that issue.ArrayQueueon the same sequence); benchmark againstArrayQueue.Seed impact
None. A new public type in
std/collectionswritten in plain TorbScript over aList; no syntax change, no new native, no runtime change (runtime/list.cstays the one storage, COLLECTIONS.md section 3.10 point 5), and the compiler looks up none of the new names by string (section 6a). Not breaking: only additions.Size
One PR, one
feat(collections)commit (plus tests and docs in the same commit or a secondtest/docsone).Common to the C7 types
std/collections/src/lib.trb(public use ...), doc comments with the cost profile of the implementation, asArrayQueuehas.tests/conformance/(.trb+.expected), run natively and in the VM, in the style ofqueue-grows.trb.benchmarks/(one small program plus its C counterpart, seebenchmarks/README.md) against the array implementation. It is a measurement, not a gate.skills/regenerated when docs change; the worker does not run gates locally, CI does.Source
RingList,ConsStack,BankersQueue,Heap(C7) #139RingList,ConsStack,BankersQueue,Heap(C7) #139[loop:torbscript] claim implement by session:loop-torbscript-20261008 until 2026-10-08T20:10:00Z
[loop:torbscript] implement: PR #203 open, CI green, next: review
==on two concrete stack values fails to compile #209