collections: RingList, a List with O(1) at both ends (C7) #197
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
RingList<Item>: an implementation ofListwhoseinsert(0, x)andremoveAt(0)are O(1), as COLLECTIONS.md section 3.4 specifies (a deque is aListimplementation, there is noDequetrait). Name settled by the owner (section 6, question 5).Acceptance criteria
public type RingList<Item> with List<Item>, From<Iterate<Item>>over a ring of slots (the technique ofArrayQueue), O(1) amortisedappend,insertat index 0 andremoveAt(0)/last removal; indexing, iteration, slices,Equals/Hashas the otherListimplementations.RingList.of(...),RingList.filled(...)and a literal with aRingListannotation work throughFrom.ArrayListon the same operation sequence.removeAt(0)againstArrayList.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-08T19:50:00Z
orion referenced this issue2026-10-08 13:52:25 +00:00
[loop:torbscript] implement: PR #201 open, CI green, next: review
==on two concrete stack values fails to compile #209const r: RingList<Int> = [1, 2]) #212PR #201 implements everything except the literal criterion (
const r: RingList<Int> = [1, 2]throughFrom). That one is tracked in #212, so the PR saysRefs #197; this issue stays open for it.RingList,ConsStack,BankersQueue,Heap(C7) #139