compress

package
v0.0.0-...-c2b2636 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HuffmanDecode

func HuffmanDecode(data []byte, codeTable Code) []byte

HuffmanDecode decodes an encoded string by HuffmanEncode function.

It receives a byte sequence and a map[byte]string Code table. This parameters is returned by HuffmanEncode function. It also returns a byte sequence for the passed encoded byte sequence

Types

type Code

type Code map[byte]string

Code is a map used to store got symbols and respective huffman codes

func HuffmanEncode

func HuffmanEncode(data []byte) ([]byte, Code)

HuffmanEncode compresses the passed data with the Huffman Coding algorithm. It returns a byte slice with encoded data and the table of in codes. example:

compress.HuffmanEncode([]byte("AAAABBBCCD")) returns:

[ '1' '1' '1' '1' '0' '0' '0' '0' '0' '0'

'0' '1' '0' '0' '1' '0' '0' '1' '1' ]

map['A': "1", 'B': "00", 'C': "010", 'D', "011"]

The map can be used for decode the encoded byte sequence

func (Code) Keys

func (c Code) Keys() []byte

Keys is a

func (Code) Reverse

func (c Code) Reverse() map[string]byte

Reverse is used for decode, when you have the string Code and wants the byte

func (Code) Values

func (c Code) Values() []string

Values TODO

Jump to

Keyboard shortcuts

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