Crates.io | stable_node_set |
lib.rs | stable_node_set |
version | 0.1.0 |
source | src |
created_at | 2023-12-07 00:33:24.040717 |
updated_at | 2023-12-07 00:33:24.040717 |
description | An ordered set with handles to values. |
homepage | |
repository | https://github.com/andriyDev/stable_node_set |
max_upload_size | |
id | 1060557 |
size | 49,346 |
A crate for an ordered set with handles to values.
Probably not. You should only use this when:
The last requirement is the most restrictive. This means you can't search for your value (perhaps it gets too expensive, or the order is unstable), or you need to be able to get the next and previous values (which is not common).
use stable_node_set::{NodeSet, NodeHandle};
fn main() {
let mut node_set = NodeSet::new();
let handle_1 = node_set.insert(1).unwrap();
let handle_2 = node_set.insert(2).unwrap();
let handle_3 = node_set.insert(3).unwrap();
assert_eq!(node_set.remove(handle_1).unwrap(), 1);
assert_eq!(node_set.remove(handle_2).unwrap(), 2);
assert_eq!(node_set.remove(handle_3).unwrap(), 3);
}
License under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.