huffman

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: BSD-2-Clause Imports: 2 Imported by: 1

README

huffman

Teeworlds huffman compression library.

Installation

go get github.com/teeworlds-go/huffman@master

Sample usage

package main

import (
	"fmt"

	"github.com/teeworlds-go/huffman"
)

func main() {
	huff := huffman.Huffman{}

	data, err := huff.Compress([]byte("hello world"))
	if err != nil {
		panic(err)
	}
	// data: [174 149 19 92 9 87 194 22 177 86 220 218 34 56 185 18 156 168 184 1]
	fmt.Printf("data: %v\n", data)


	data, err = huff.Decompress([]byte{174, 149, 19, 92, 9, 87, 194, 22, 177, 86, 220, 218, 34, 56, 185, 18, 156, 168, 184, 1})
	if err != nil {
		panic(err)
	}
	// data: hello world
	fmt.Printf("data: %v\n", string(data))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Huffman

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

func (*Huffman) Compress

func (huff *Huffman) Compress(data []byte) ([]byte, error)

func (*Huffman) Decompress

func (huff *Huffman) Decompress(data []byte) ([]byte, error)

func (*Huffman) Init

func (huff *Huffman) Init()

Jump to

Keyboard shortcuts

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