Crate ds_ext

Source
Expand description

This crate repackages standard data structures with additional capabilities, like fast ordered maps and sets.

OrdHashSet uses a Vec internally for ordering. OrdHashSet and OrdHashMap both implement a bisect method which allows looking up a key by comparison, potentially avoiding the need for a heap allocation to construct a search key..

Features:

  • all: enables all features
  • serialize: enables support for serde.
  • stream: enables support for destream.
  • hash: enables support for async-hash.

Example usage:

use ds_ext::*;

let mut set = OrdHashSet::new();
assert!(set.is_empty());

set.insert(1);
assert!(set.contains(&1));
assert_eq!(set.len(), 1);

let mut map = OrdHashMap::from_iter(set.into_iter().map(|i| (i, i)));
assert_eq!(map.len(), 1);

assert_eq!(map.get(&1), map.bisect(|i| i.partial_cmp(&1)));

Re-exports§

pub use map::OrdHashMap;
pub use queue::LinkedHashMap;
pub use set::OrdHashSet;

Modules§

map
A hash map ordered by key using a linked hash set
queue
A linked hash map ordered by insertion which can be reordered by swapping, useful as a simple priority queue (e.g. an LFU or LRU cache).
set
A hash set ordered using a Vec.