def qrm

bend-collections@1.0.0.0 · src/containers/lru.bend:666

import bend-collections@1.0.0.0/src/containers/lru.bend as Lru
import Base
import bend-collections@1.0.0.0/src/containers/hash_table.bend as H

666# Fused one-character remove: the probe loop finishes the operation itself,
667# so no continuation is pushed around it.
668def qrm(a, -V: Kind(a), fuel: Nat, s: H.QStep, +mask: U32, +w: U32, +i: U32, +cap: U32, +n: U32, +head: U32, +tail: U32, +free: U32, m: Array<U32>, ks: Array<String>, ents: Array<Maybe<a, V>>, lk: Array<U32>) -> LRU<a, V> & Maybe<a, V>:
669  match fuel s:
670    case 0n H.QEnd{tab}:
671      (F{cap, n, head, tail, free, m, tab, ks, ents, lk}, None{})
672    case 0n H.QHit{tab, +l}:
673      drop_slot(a, V, F{cap, n, head, tail, free, m, H.del_at(tab, mask, i), ks, ents, lk}, H.slot(l), 2)
674    case 0n H.QNext{tab}:
675      (F{cap, n, head, tail, free, m, tab, ks, ents, lk}, None{})
676    case 1n+p H.QEnd{tab}:
677      (F{cap, n, head, tail, free, m, tab, ks, ents, lk}, None{})
678    case 1n+p H.QHit{tab, +l}:
679      drop_slot(a, V, F{cap, n, head, tail, free, m, H.del_at(tab, mask, i), ks, ents, lk}, H.slot(l), 2)
680    case 1n+p H.QNext{tab}:
681      +j = H.bnext(i, mask)
682      qrm(a, V, p, H.qstep(tab, j, w), mask, w, j, cap, n, head, tail, free, m, ks, ents, lk)

Uses (14)

Used by (1)