palettevec

Crates.iopalettevec
lib.rspalettevec
version
sourcesrc
created_at2025-01-05 21:27:11.623048
updated_at2025-01-07 18:43:48.757106
descriptionA palette compressed vector library for potentially insane runtime compression ratios.
homepage
repositoryhttps://github.com/alexdesander/palettevec
max_upload_size
id1505065
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Alexdesander (alexdesander)

documentation

README

PaletteVec

PaletteVec is space efficient data structure for storing and managing items with a limited set of repeated elements, using a palette-based encoding scheme.

Palette compression has the following advantages:

  • Potentially insane compression ratios
  • Buffer can be manipulated without decompressing
  • Easy to use

Disadvantages:

  • Buffer accesses come with a runtime cost
  • Large palettes (large amount of distinct items) come with a runtime cost of O(palette entries) per buffer access

Use cases

Palette compression has potential to save huge amounts of memory at runtime while still allowing for manipulation of the buffer elements. Most notably, palette compression is used in minecraft for block chunk storage. For most sophisticated voxel games, palette compression is a must.

Palette compression is also used in image compression (Indexed Color Images) and audio compression.

Example

Creating and using a PaletteVec:

use palettevec::PaletteVec;

fn main() {
    let mut vec = PaletteVec::new();

    // Push elements
    vec.push("apple");
    vec.push("banana");
    vec.push("apple");

    // Access elements
    assert_eq!(vec[0], "apple");
    assert_eq!(vec[1], "banana");

    // Modify elements
    vec.set(1, "cherry");
    assert_eq!(vec[1], "cherry");

    // Remove elements
    assert_eq!(vec.pop(), Some(&"apple"));

    // Iterate over elements
    for item in &vec {
        println!("{}", item);
    }
    // Optimizing the palette
    vec.optimize();
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 8

cargo fmt