It seems ic_stable_structures BTreeMap
and Vec
do not implement the DoubleEndedIterator
trait for their Iterators.
How do we .iter().rev()
on these structures?
(Iterate by shared reference in reverse order)
It seems ic_stable_structures BTreeMap
and Vec
do not implement the DoubleEndedIterator
trait for their Iterators.
How do we .iter().rev()
on these structures?
(Iterate by shared reference in reverse order)
Hi @Samer, a DoubleEndedIterator
has already been implemented for Vec
in this PR but it hasn’t been released yet. I believe @hpeebles is planning on writing a DoubleEndedIterator
for BTreeMap
as well, and without that, iterating in reverse order in BTreeMap
is not yet possible unfortunately.
I created an issue to track this.
I would love to implement it for BTreeMap
if I get time, but realistically its unlikely I’ll do it any time soon since it isn’t a high priority for me compared to some of the OpenChat stuff we have lined up.
The workaround is obvious for now.
We convert (parts of) the stable structure into a heap structure and reverse iterate on that. This works for small data sets for now
Looking forward to the impl!