colony

Crates.iocolony
lib.rscolony
version0.3.0
sourcesrc
created_at2023-07-31 12:56:18.013958
updated_at2023-08-04 15:16:00.690327
descriptionA fast associative data-structure that chooses its own keys
homepagehttps://github.com/LlewVallis/colony
repositoryhttps://github.com/LlewVallis/colony
max_upload_size
id930840
size74,003
(LlewVallis)

documentation

https://docs.rs/colony

README

Colony

Tests Crates.io Docs

An unordered data-structure with O(1) lookup, removal, iteration and O(1) amortized insertion. Like a faster HashMap that chooses its own keys. Also similar to a Vec<Option<T>>, where instead of calling Vec::remove elements are removed by setting the element to None.

See the documentation for more information.

This crate is partly a port of plf::colony, which is a proposed addition to the C++ standard library under the name std::hive.

Example

let mut colony = Colony::new();

// Insert
let foo_handle = colony.insert("foo");
let bar_handle = colony.insert("bar");

// Remove
assert_eq!(colony.remove(foo_handle), Some("foo"));

// Lookup
assert_eq!(colony.get(foo_handle), None);
assert_eq!(colony.get(bar_handle), Some(&"bar"));

// Iteration
for (key, &value) in colony.iter() {
    assert_eq!((key, value), (bar_handle, "bar"));
}
Commit count: 18

cargo fmt