envzn
0.8 · beta · not released

Library / Collections / Lists / OwnedList

CLASSIMPLEMENTS Collection<T>

OwnedList

Owning, move-only, non-Cloneable list.

Fields 1

int32 length

Constructors 1

INIT()

Methods 6

MODIFY METHOD add(T value) RETURNS uint64
modifies

Take ownership of value and prepend it (right after the head sentinel). O(1). Returns the new node's stable id, which the caller passes to removeById later.

Splice ordering: step 1: newNode.next := .head.next (move old first into newNode.next) step 2: .head.next := newNode (move newNode into .head.next)

MODIFY METHOD removeById(uint64 id) RETURNS boolean
modifies

Remove the user node with the given id. Returns TRUE if found and removed; FALSE if no live node carries that id. Walks from the head sentinel tracking the predecessor, then splices the target out (its owned element is dropped as popped leaves scope).

METHOD findById(uint64 id) RETURNS | REFERENCE T
reads

Return a REFERENCE to the element of the node with the given id. Pipe-XOR: SUCCESS yields the reference; FAILURE if no live node carries that id. Used by MessageBroker.subscribe to hand a Subscription a non-owning handle to its just-added channel.

METHOD size() RETURNS int64
reads

Countable — the count of user nodes (sentinels excluded). .length is the int32 field; size() is the int64 contract, and int32 -> int64 is a widening, so the assignment carries it with no stated conversion.

METHOD isEmpty() RETURNS boolean
reads
METHOD iterator() RETURNS OwnedListIterator[T]
reads

Fresh forward cursor positioned at the first user node (or the ender if empty). Pass .head by-& so the iterator's REFERENCE binding is mutation-locked at INIT without moving .head out.