Working data structure, optimal seed

This commit is contained in:
Ian Gulliver
2023-12-30 20:14:01 -07:00
parent ac2dfbb5d1
commit 780a9b599b
6 changed files with 140 additions and 132 deletions

View File

@@ -6,15 +6,15 @@ import (
"github.com/icza/bitio"
"github.com/samber/lo"
"github.com/securemesh/coding/codes"
"github.com/securemesh/coding/heap"
"github.com/securemesh/coding/state"
)
func Encode(h *heap.Heap, msg []byte) []byte {
func Encode(st *state.State, msg []byte) []byte {
buf := &bytes.Buffer{}
w := bitio.NewWriter(buf)
for _, b := range msg {
index := h.IncrementSymbol(b)
index := st.IncrementSymbol(b)
code := codes.CodeForIndex(index)
lo.Must0(w.WriteBits(uint64(code.Value), uint8(code.Bits)))
}