-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Map
s and Deque
s are great. But how to combine them? Both a list of maps and a map of lists are interesting.
In order to get a map of Deque
s I currently have to use a workaround like this:
/// Add an element to the unprocessed drand jobs queue of this round
pub fn jobs_queue_enqueue(storage: &mut dyn Storage, round: u64, value: &Job) -> StdResult<()> {
let prefix = format!("drand_jobs_{:0>10}", round);
Deque::new(&prefix).push_back(storage, value)
}
/// Remove an element from the unprocessed drand jobs queue of this round
pub fn jobs_queue_dequeue(storage: &mut dyn Storage, round: u64) -> StdResult<Option<Job>> {
let prefix = format!("drand_jobs_{:0>10}", round);
Deque::new(&prefix).pop_front(storage)
}
I.e. I have to create new Deque
s on the fly after composing the correct key. It works but does not look beautiful. Wouldn't it be great to make a DequeMap instead which has all the power of key composability of a Map
plus many storage items (a deque) per key? That would allow maps of stacks as well as maps of queues.
uint
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request