Method
Encode
(enc *Encoder, value uint)
Source from the content-addressed store, hash-verified
| 121 | } |
| 122 | |
| 123 | func (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 | |
| 142 | func (tree Tree) Decode(dec *Decoder) (value uint) { |
| 143 | ctx := uint(1) |
Callers
nothing calls this directly
Tested by
no test coverage detected