compressor

package module
v0.0.0-...-868b9b3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

README

Compressor - Simple Repeated Characters Compression Algorithm (Go Version)

This Go package provides a Go implementation of a symmetric compression algorithm designed for sequences containing repeated characters. The algorithm aims to reduce the size of data by efficiently encoding repeated character chunks.

Installation

To use this package, you can import it into your Go project:

go get -u github.com/NIR3X/compressor

Usage

Here is an example of how to use the Compressor package in your Go application:

package main

import (
	"fmt"
	"github.com/NIR3X/compressor"
)

func main() {
	// Data to compress
	data := []uint8("Hellooooooooooo, World!")

	// Compress the data
	var compressed []uint8
	compressedSize := compressor.Compress(data, &compressed)

	// Decompress the data
	decompressed := make([]uint8, len(data))
	decompressedSize := compressor.Decompress(compressed, decompressed)

	// Print original, compressed, and decompressed sizes
	fmt.Printf("Original Size: %d bytes\n", len(data))
	fmt.Printf("Compressed Size: %d bytes\n", compressedSize)
	fmt.Printf("Decompressed Size: %d bytes\n", decompressedSize)

	// Print original and decompressed data
	fmt.Printf("Original Data: %s\n", data)
	fmt.Printf("Decompressed Data: %s\n", string(decompressed))
}

In this example, the Compressor package compresses the input data, and then decompresses it, demonstrating the basic usage of the compression and decompression functionalities. Adjust the package integration as needed for your specific use case.

License

GNU AGPLv3 Image

This program is Free Software: You can use, study share and improve it at your will. Specifically you can redistribute and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Documentation

Index

Constants

View Source
const (
	MinChunkSize                 = 3
	ChunkSame, ChunkMixed uint64 = 0, 1
)

Variables

This section is empty.

Functions

func Compress

func Compress(src []uint8, pDest *[]uint8) uint64

func Decompress

func Decompress(src, dest []uint8) uint64

func GetNextChunkSame

func GetNextChunkSame(src []uint8, pos uint64, left, right *uint64) bool

func PutChunkMixed

func PutChunkMixed(src []uint8, i *uint64, iEnd uint64, dest []uint8, destPos *uint64)

Types

This section is empty.

Jump to

Keyboard shortcuts

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