#crdt #local-first #collaborative-editing

loro-rle

A internal library of loro for storing and manipulating run-length encoded data. Do not use it directly.

5 releases (3 breaking)

new 0.5.1 May 6, 2024
0.5.0 Apr 29, 2024
0.4.0 Apr 9, 2024
0.2.0 Feb 16, 2024
0.1.0 Nov 28, 2023

#824 in Data structures

Download history 1/week @ 2024-01-14 151/week @ 2024-02-11 38/week @ 2024-02-18 48/week @ 2024-02-25 6/week @ 2024-03-03 10/week @ 2024-03-10 4/week @ 2024-03-17 6/week @ 2024-03-24 57/week @ 2024-03-31 158/week @ 2024-04-07 12/week @ 2024-04-14 5/week @ 2024-04-21 173/week @ 2024-04-28

358 downloads per month
Used in 4 crates (2 directly)

MIT license

31KB
898 lines

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 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.

Dependencies

~1–1.5MB
~33K SLoC