skiplist-rs

Crates.ioskiplist-rs
lib.rsskiplist-rs
version0.1.5
sourcesrc
created_at2020-04-19 18:46:41.961241
updated_at2022-01-01 09:57:02.812332
descriptionSkip 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.
homepagehttps://github.com/bangbaoshi/skiplist-rs
repositoryhttps://github.com/bangbaoshi/skiplist-rs
max_upload_size
id231992
size18,994
(bangbaoshi)

documentation

https://github.com/bangbaoshi/skiplist-rs

README

skiplist-rs

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.

How To Use

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());
    }

}

License

This library is licensed under MIT license. See LICENSE for details.

Commit count: 14

cargo fmt