def Vec.push.grow

bend-kit-collections@0.1.4.1 · vec.bend:32

import bend-kit-collections@0.1.4.1/vec.bend as Vec
import Base

32def Vec.push.grow(
33  ~T: Data, full: Bool, +n: U32, +x: T, buf: Array<T>, +cap: U32
34) -> Vec<T>:
35  match full:
36    case False{}:
37      Vec{U32.inc(n), Array.set(T, buf, n, x)}
38    case True{}:
39      # Every slot of big starts as x, so slot n needs no write.
40      big = Array.new(T, 1n+U32.log2(cap), x)
41      Vec{U32.inc(n), Vec.copy(~T, U32.to_nat(n), 0, big, Array.get(T, buf, 0))}

Uses (12)

Used by (1)