def endpoint

bend-collections@1.0.0.0 · src/containers/dlist_iterator.bend:24

import bend-collections@1.0.0.0/src/containers/dlist_iterator.bend as DlistIterator
import Base
import bend-collections@1.0.0.0/src/containers/doubly_linked_list.bend as D
import bend-collections@1.0.0.0/src/containers/internal/dlist_storage.bend as R

24# Cursor links are arena indices plus one; zero is the gap past the end.
25# Only this owning iterator can mutate the list until finish. Public handles
26# retain their owner and generation; a cursor is never exposed as a handle.
27def endpoint(~T: Data, s: D.DList<T>, +front: Bool) -> D.DList<T> & U32:
28  D.DL{tag, depth, cap, raw, gens} = s
29  R.DL{owner, fresh, free, count, +head, +tail, rd, rc, vals, prevs, nexts} = raw
30  (D.DL{tag, depth, cap, R.DL{owner, fresh, free, count, head, tail, rd, rc, vals, prevs, nexts}, gens}, choose(U32, front, head, tail))

Uses (7)

Used by (1)