huffman

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 4 Imported by: 0

README

Huffman compression

func Example() {
	data := []byte("zhang how, zhang how, zhang how, zhang how,")
	compressed := Compress(data)
	fmt.Printf("performance %.4f\n", float64(len(compressed))/float64(len(data)))
	de, _ := Decompress(compressed)
	fmt.Println(string(de))

	// Output:
	// performance 0.7674
	// zhang how, zhang how, zhang how, zhang how,
}

Documentation

Overview

Example
data := []byte("zhang how, zhang how, zhang how, zhang how,")
compressed := Compress(data)
fmt.Printf("performance %.4f\n", float64(len(compressed))/float64(len(data)))
de, _ := Decompress(compressed)
fmt.Println(string(de))
Output:

performance 0.7674
zhang how, zhang how, zhang how, zhang how,

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(data []byte) []byte

Compress data using huffman algorithm

func Decompress

func Decompress(data []byte) ([]byte, error)

Decompress data compressed by huffman algorithm

Types

This section is empty.

Jump to

Keyboard shortcuts

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