huffslice

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package huffslice compresses a slice using Huffman encoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder[T comparable] struct {
	Slice       slice.Slice[T]
	SingleToken T
}

Encoder is used to create the Slice.

func NewEncoder

func NewEncoder[T comparable](ln int, singleToken T) *Encoder[T]

NewEncoder creates a slice with a capacity of ln and sets the values for the single token.

func (*Encoder[T]) Encode

func (e *Encoder[T]) Encode() *Slice[T]

Encode to Slice.

type Slice

type Slice[T comparable] struct {
	huffman.Tree[T]
	Encoded *rye.Bits
	// Values that occure a single time are replaced wit SingleToken and stored
	// speratly from the Tree.
	Singles     slice.Slice[T]
	SingleToken T
}

Slice encoded using Huffman compression

func (*Slice[T]) Iter

func (s *Slice[T]) Iter() liter.Iter[T]

Iter creates an iterator for decoding the Slice.

Jump to

Keyboard shortcuts

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