You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maps and Deques 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 Deques I currently have to use a workaround like this:
/// Add an element to the unprocessed drand jobs queue of this roundpubfnjobs_queue_enqueue(storage:&mutdynStorage,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 roundpubfnjobs_queue_dequeue(storage:&mutdynStorage,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 Deques 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.
The text was updated successfully, but these errors were encountered:
Map
s andDeque
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: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 aMap
plus many storage items (a deque) per key? That would allow maps of stacks as well as maps of queues.The text was updated successfully, but these errors were encountered: