loro/crates/rle/src/lib.rs

38 lines
1.4 KiB
Rust
Raw Normal View History

2022-08-04 07:26:38 +00:00
//! Run length encoding library.
//!
//! There are many mergeable types. By merging them together we can get a more compact representation of the data.
//! For example, in many cases, `[0..5, 5..10]` can be merged into `0..10`.
//!
//! # RleVec
//!
//! RleVec<T> is a vector that can be compressed using run-length encoding.
//!
//! A T value may be merged with its neighbors. When we push new element, the new value
//! may be merged with the last element in the array. Each value has a length, so there
//! are two types of indexes:
//! 1. (merged) It refers to the index of the merged element.
//! 2. (atom) The index of substantial elements. It refers to the index of the atom element.
//!
//! By default, we use atom index in RleVec.
//! - len() returns the number of atom elements in the array.
//! - get(index) returns the atom element at the index.
//! - slice(from, to) returns a slice of atom elements from the index from to the index to.
//!
2022-09-01 17:14:39 +00:00
//!
#![allow(dead_code)]
2022-09-20 07:31:18 +00:00
#![deny(clippy::undocumented_unsafe_blocks)]
2022-09-02 08:49:06 +00:00
pub mod range_map;
2022-07-26 18:24:25 +00:00
mod rle_trait;
pub mod rle_tree;
2022-07-26 18:24:25 +00:00
mod rle_vec;
mod rle_vec_old;
2022-10-24 09:17:27 +00:00
pub use crate::rle_trait::{HasIndex, HasLength, Mergable, Rle, Slice, Sliceable, ZeroElement};
2022-12-06 07:40:56 +00:00
pub use crate::rle_vec::{RleVec, RleVecWithLen};
pub use crate::rle_vec_old::{RleVecWithIndex, SearchResult, SliceIterator};
2022-10-08 08:04:25 +00:00
pub mod rle_impl;
2022-08-12 12:46:38 +00:00
pub use rle_tree::tree_trait::RleTreeTrait;
pub use rle_tree::RleTree;
2022-10-31 12:06:56 +00:00
mod small_set;
#[cfg(test)]
mod test;