Skip to content

timurinal/rle-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

rle-compression

Basic single-file RLE compression in C#

Use however you want, credit is not required but appreciated :)

Works with any C# struct. If you use it with custom structs, make sure to implement Equals(object? other) to avoid any expensive boxing

The speed will differ from system to system, but I averaged 2ms for 100,000 values on my PC

This was made more for fun, but could serve some practical use

Usage

using Compression;

class Program 
{
	static void Main(string[] args) 
	{
		int[] data = [ 1, 1, 1, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5 ]

		byte[] compressed = Compression.Compress(data);

		int[] decompressed = Compression.Decompress<int>(compressed);
	}
}

Installation

Simply add the Compression.cs file to your project, and you're good to go.

About

Basic RLE compression in C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages