Crates.io | skiplist-rs |
lib.rs | skiplist-rs |
version | 0.1.5 |
source | src |
created_at | 2020-04-19 18:46:41.961241 |
updated_at | 2022-01-01 09:57:02.812332 |
description | Skip list is a kind of ordered map and can store any value inside. See skip list wikipedia page to learn more about this data structure. |
homepage | https://github.com/bangbaoshi/skiplist-rs |
repository | https://github.com/bangbaoshi/skiplist-rs |
max_upload_size | |
id | 231992 |
size | 18,994 |
Skip list is a kind of ordered map and can store any value inside. See skip list wikipedia page to learn more about this data structure.
fn main() {
let mut list = Skiplist::new();
list.set(10, "helloworld".to_string());
if let Some(t) = list.get(&10) {
println!("{}", t);
}
list.remove(&10);
if let Some(t) = list.get(&10) {
println!("{}", t);
} else {
println!("not found");
}
}
#[test]
fn test_iterator() {
let mut rng = rand::thread_rng();
let y: f64 = rng.gen();
let mut nums: Vec<u32> = (1..200).collect();
nums.shuffle(&mut rng);
let mut skiplist = Skiplist::new();
for i in nums {
println!("index is {}", i);
skiplist.set(i, format!("Helloworld_{}", i));
}
for v in &mut skiplist {
println!("{}", v.as_str());
}
skiplist.set(9999, "Helloworld_9999".to_string());
for v in &mut skiplist {
println!("{}", v.as_str());
}
}
This library is licensed under MIT license. See LICENSE for details.