dequemap
English | 简体中文
dequemap provides a double-ended queue with map features. It combines a VecDeque index with a BTreeMap or HashMap backend, allowing push/pop from both ends while maintaining key-value access.
Supports no_std environments with alloc.
Features
- DequeBTreeMap — ordered map with double-ended queue operations
- DequeHashMap — hash map with double-ended queue operations
- Entry API (VacantEntry / OccupiedEntry) similar to std's map entries
no_stdcompatible- Optional serde support
- Push front/back, pop front/back, remove, retain, clear
Cargo Feature Flags
| Feature | Description | Default |
|---|---|---|
std |
Use Rust standard library (std) |
yes |
btreemap |
Enable DequeBTreeMap (ordered backend) |
yes |
hashmap |
Enable DequeHashMap (hash backend, pulls in hashbrown) |
no |
serde |
Enable serialization/deserialization support | no |
Basic Usage
use DequeBTreeMap;
let mut map = new;
map.push_back;
map.push_back;
map.push_front;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Tests
30 tests covering both backends, Entry API, serde roundtrip, large entries, and edge cases.
License
Licensed under either of Apache License 2.0 or MIT license at your option.