def pop_with
bend-collections@1.0.0.0 · src/containers/binary_heap.bend:261
import bend-collections@1.0.0.0/src/containers/binary_heap.bend as BinaryHeap
import Base
import bend-collections@1.0.0.0/src/containers/types/binary_heap.bend as E
261
262
263
264
265
266
267def pop_with(~A: Data, ~cmp: A -> A -> Cmp, size: Nat, +n: U32, depth: Nat, cap: U32, arr: Array<Maybe<&2, A>>, mr: Maybe<&2, A>) -> Heap<A> & Result<&2, &2, E.Error, A>:
268 match mr:
269 case None{}:
270 (BH{size, n, depth, cap, arr}, Fail{E.EmptyHeap{}})
271 case Some{+root}:
272 pop_last(~A, ~cmp, Nat.sub(size, 1n), U32.sub(n, 1), depth, cap, root, Array.get(Maybe<&2, A>, arr, U32.sub(n, 1)))