File: rle_test.go

package info (click to toggle)
golang-github-anacrolix-missinggo 2.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 836 kB
  • sloc: makefile: 4
file content (20 lines) | stat: -rw-r--r-- 418 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package missinggo_test

import (
	"fmt"

	"github.com/anacrolix/missinggo"
)

func ExampleNewRunLengthEncoder() {
	var s string
	rle := missinggo.NewRunLengthEncoder(func(e interface{}, count uint64) {
		s += fmt.Sprintf("%d%c", count, e)
	})
	for _, e := range "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" {
		rle.Append(e, 1)
	}
	rle.Flush()
	fmt.Println(s)
	// Output: 12W1B12W3B24W1B14W
}