| Crates.io | colony |
| lib.rs | colony |
| version | 0.3.0 |
| created_at | 2023-07-31 12:56:18.013958+00 |
| updated_at | 2023-08-04 15:16:00.690327+00 |
| description | A fast associative data-structure that chooses its own keys |
| homepage | https://github.com/LlewVallis/colony |
| repository | https://github.com/LlewVallis/colony |
| max_upload_size | |
| id | 930840 |
| size | 74,003 |
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.
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"));
}