stable-structures icon indicating copy to clipboard operation
stable-structures copied to clipboard

Add more methods to BTreeMap

Open peterpeterparker opened this issue 2 years ago • 1 comments

Motivation

I am currently implementing the ic-stable-structures in Juno and I whish following methods would have been available as they are in the standard BTreeMap.

Note

None are blocker as they can be solved using iter() and other operator.

List

WIP: I'll update the list according my progress. Here are those already known:

  • keys() & into_keys()
  • values() & into_values()
  • into_iter() (?)

peterpeterparker avatar Jun 02 '23 10:06 peterpeterparker

The difference between foo() and into_foo() is that the former returns a reference while the latter returns a full copy of the data. In our case, since data is being read from stable storage, it cannot be returned as a reference, so our iter(), for example, is the equivalent of into_iter() in the standard library.

key() and values() would be nice. In the meantime, you can extract that information from the iter(), but I agree it's good to add more consistency with the standard library.

ielashi avatar Jun 23 '23 11:06 ielashi