mirror of
https://github.com/loro-dev/loro.git
synced 2024-12-03 21:18:25 +00:00
27 lines
868 B
Rust
27 lines
868 B
Rust
mod string_tree;
|
|
use rle::RleTree;
|
|
use string_tree::{CustomString, StringTreeTrait};
|
|
|
|
pub fn main() {
|
|
let mut tree: RleTree<CustomString, StringTreeTrait> = RleTree::default();
|
|
let len = 1e6 as usize;
|
|
let mut seed = 2;
|
|
|
|
tree.with_tree_mut(|tree| {
|
|
for i in 0..(len) {
|
|
seed = (seed * 2) % 10000007;
|
|
if tree.len() > 100000 {
|
|
let start = i % tree.len();
|
|
let len = seed % std::cmp::min(tree.len(), 1);
|
|
let end = std::cmp::min(start + len, tree.len());
|
|
tree.delete_range(Some(start), Some(end))
|
|
} else if tree.len() == 0 {
|
|
tree.insert(0, "0".into());
|
|
} else {
|
|
tree.insert(seed % tree.len(), "a".into());
|
|
}
|
|
}
|
|
|
|
println!("{} op, with tree size of {}", len, tree.len());
|
|
});
|
|
}
|