Split out heap
This commit is contained in:
@@ -2,11 +2,13 @@ package coding
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/icza/bitio"
|
"github.com/icza/bitio"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
|
"github.com/securemesh/coding/heap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Encode(h *Heap, msg []byte) []byte {
|
func Encode(h *heap.Heap, msg []byte) []byte {
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
w := bitio.NewWriter(buf)
|
w := bitio.NewWriter(buf)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package coding
|
package heap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"maps"
|
"maps"
|
||||||
10
seeds.go
10
seeds.go
@@ -1,5 +1,9 @@
|
|||||||
package coding
|
package coding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/securemesh/coding/heap"
|
||||||
|
)
|
||||||
|
|
||||||
var chatHeap = newHeapFromSeed([][]byte{
|
var chatHeap = newHeapFromSeed([][]byte{
|
||||||
[]byte(`]\_}`),
|
[]byte(`]\_}`),
|
||||||
[]byte(`[ê%=Z`),
|
[]byte(`[ê%=Z`),
|
||||||
@@ -18,12 +22,12 @@ var chatHeap = newHeapFromSeed([][]byte{
|
|||||||
[]byte(` `),
|
[]byte(` `),
|
||||||
})
|
})
|
||||||
|
|
||||||
func ChatHeap() *Heap {
|
func ChatHeap() *heap.Heap {
|
||||||
return chatHeap.Clone()
|
return chatHeap.Clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHeapFromSeed(seed [][]byte) *Heap {
|
func newHeapFromSeed(seed [][]byte) *heap.Heap {
|
||||||
h := NewHeap()
|
h := heap.NewHeap()
|
||||||
|
|
||||||
for i := range seed {
|
for i := range seed {
|
||||||
for _, s := range seed[i:] {
|
for _, s := range seed[i:] {
|
||||||
|
|||||||
Reference in New Issue
Block a user