ds_ext/lib.rs
1//! This crate repackages standard data structures with additional capabilities,
2//! like fast ordered maps and sets.
3//!
4//! [`OrdHashSet`] uses a [`Vec`] internally for ordering.
5//! [`OrdHashSet`] and [`OrdHashMap`] both implement a `bisect` method
6//! which allows looking up a key by comparison,
7//! potentially avoiding the need for a heap allocation to construct a search key..
8//!
9//! Features:
10//! - `all`: enables all features
11//! - `serialize`: enables support for [`serde`](https://docs.rs/serde/).
12//! - `stream`: enables support for [`destream`](https://docs.rs/destream/).
13//! - `hash`: enables support for [`async-hash`](https://docs.rs/async-hash/).
14//!
15//!
16//! Example usage:
17//! ```
18//! use ds_ext::*;
19//!
20//! let mut set = OrdHashSet::new();
21//! assert!(set.is_empty());
22//!
23//! set.insert(1);
24//! assert!(set.contains(&1));
25//! assert_eq!(set.len(), 1);
26//!
27//! let mut map = OrdHashMap::from_iter(set.into_iter().map(|i| (i, i)));
28//! assert_eq!(map.len(), 1);
29//!
30//! assert_eq!(map.get(&1), map.bisect(|i| i.partial_cmp(&1)));
31//! ```
32
33#[cfg(feature = "hash")]
34mod hash;
35#[cfg(feature = "serialize")]
36mod serial;
37#[cfg(feature = "stream")]
38mod stream;
39
40pub mod map;
41pub mod queue;
42pub mod set;
43
44pub use map::OrdHashMap;
45pub use queue::LinkedHashMap;
46pub use set::OrdHashSet;