RedRLE:
Filter:
redSys/Classes (extension) | Red > redTools

RedRLE
ExtensionExtension

run-length compression/decompression

Description

See http://en.wikipedia.org/wiki/Run-length_encoding

Performs well with highly repetitive data e.g. [0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3]. Performs very bad with data containing repeating patterns e.g. [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3].

NOTE: Works with Integer, Float and Symbol. Can also take a String instead of an Array.

Class Methods

.encode

Returns an array with length, value pairs.

.decode

Array must be length, value pairs.

Examples