Render

Flat Map

A map backed by sorted slices, demoing the p/moul/x/daily/flatmap library.

Sorted by construction

Inserted as delta, alpha, echo, bravo, charlie — stored sorted:

#keyvalue
0alpha2
1bravo4
2charlie5
3delta1
4echo3

No sort on read, and no dependence on map iteration order — which gno leaves unspecified, and which would let two nodes render different pages from the same state.

Indexed access

Sorted storage gives positional lookup that a hash map cannot:

  • At(0) → alpha = 2
  • At(2) → charlie = 5
  • At(4) → echo = 3

Range queries

Two binary searches and a walk — lo inclusive, hi exclusive:

rangekeys
["bravo", "delta")bravo, charlie
["charlie", ∞)charlie, delta, echo
["b", "d")bravo, charlie

The last one asks for bounds that are not keys at all — the search still lands in the right place.

The trade

operationcost
GetO(log n) binary search over contiguous memory
iterationO(n), already ordered, nothing to sort
Set in the middleO(n) — the tail shifts
Set at the endO(1) amortised — the fast path

Cheap reads and cheap ordered iteration, paid for at write time.

Transactions

Calls, deploys, and child packages · indexed history

No indexed transactions for this realm yet.

Call function

No qfuncs for this package · calls stay disabled

Source (qfile)