MCPcopy Create free account
hub / github.com/egonelbre/exp / Encode

Method Encode

coder/arith/models.go:123–140  ·  view source on GitHub ↗
(enc *Encoder, value uint)

Source from the content-addressed store, hash-verified

121}
122
123func (tree Tree) Encode(enc *Encoder, value uint) {
124 if value > tree.syms() {
125 panic("")
126 }
127
128 syms, msb := tree.syms(), tree.msb()
129 ctx := uint(1)
130 for ctx < syms {
131 bit := uint(0)
132 if value&msb != 0 {
133 bit = 1
134 }
135
136 value += value
137 tree[ctx-1].Encode(enc, bit)
138 ctx += ctx + bit
139 }
140}
141
142func (tree Tree) Decode(dec *Decoder) (value uint) {
143 ctx := uint(1)

Callers

nothing calls this directly

Calls 3

symsMethod · 0.95
msbMethod · 0.95
EncodeMethod · 0.65

Tested by

no test coverage detected