scapegoat

crates.io GitHub Actions

Ordered set and map data structures via an arena-based scapegoat tree (memory-efficient, self-balancing binary search tree).

About

Three APIs:

Strives for two properties:

Other features:

Usage

SGMap non-exhaustive API example (would work identically for std::collections::BTreeMap):

```rust use scapegoat::SGMap;

let mut example = SGMap::new();

example.insert(3, String::from("the")); example.insert(2, String::from("don't blame")); example.insert(1, String::from("Please")); example.insert(4, String::from("borrow checker"));

asserteq!( (&example).intoiter().map(|(_, v)| v).collect::>(), vec!["Please","don't blame","the","borrow checker"] );

assert_eq!(example[&3], "the");

let pleasetuple = example.popfirst().unwrap(); asserteq!(pleasetuple, (1, String::from("Please")));

example.insert(5, String::from("! :P"));

let dontblame = example.getmut(&2).unwrap(); dontblame.remove(0); dontblame.insert(0, 'D');

asserteq!( example.intoiter().map(|(_, v)| v).collect::>(), vec!["Don't blame","the","borrow checker","! :P"] ); ```

Note

This project is an exercise in safe datastructure design. It's not as mature, fast, or memory efficient as the standard library's BTreeMap/BTreeSet.