algorithm

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2023 License: MIT Imports: 0 Imported by: 0

README

algorithm 算法模块

crc16_test.go crc16算法

TestCrc16

t.Log(Crc16([]byte("abcdefg汉字")))
TestCrc16s

t.Log(Crc16s("abcdefg汉字") == Crc16([]byte("abcdefg汉字")))

descartes_test.go 笛卡尔组合

TestDescartes

result := DescartesCombine([][]string{{"A", "B"}, {"1", "2", "3"}, {"a", "b", "c", "d"}})
for _, item := range result {
	t.Log(item)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Crc16

func Crc16(bs []byte) (crc uint16)

func Crc16s added in v1.1.21

func Crc16s(str string) (crc uint16)

func DescartesCombine

func DescartesCombine(dimValue [][]string) [][]string

func Kermit

func Kermit(byteArray []byte) uint16

* * CRC-CCITT (Kermit) * test data source http://www.lammertbies.nl/comm/info/crc-calculation.html

Types

type C2 added in v1.1.35

type C2 struct {
	// contains filtered or unexported fields
}

C2 is a circular buffer intended to allow you to write a block of data of up to 'blocksize', and retrieve the data evicted by that operation, without allocating any extra slice storage

This requires that it keep at least blocksize*2 data around. In fact, it doubles that again in order to guarantee that both of these bits of information can always be obtained in a single contiguous block of memory.

Other than the cost of the extra memory (4xblocksize), this means that it requires 2 writes for every byte stored.

func MakeC2Buffer added in v1.1.35

func MakeC2Buffer(blockSize int) *C2

func (*C2) Empty added in v1.1.35

func (c *C2) Empty() bool

func (*C2) Evicted added in v1.1.35

func (c *C2) Evicted() []byte

get the data that was evicted by the last write

func (*C2) GetBlock added in v1.1.35

func (c *C2) GetBlock() []byte

get the current buffer contents of block

func (*C2) Len added in v1.1.35

func (c *C2) Len() int

func (*C2) Reset added in v1.1.35

func (c *C2) Reset()

func (*C2) Truncate added in v1.1.35

func (c *C2) Truncate(byteCount int) (evicted []byte)

Shortens the content of the circular buffer and returns the content removed

func (*C2) Write added in v1.1.35

func (c *C2) Write(b []byte)

Write new data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL