heapless icon indicating copy to clipboard operation
heapless copied to clipboard

Add usize index methods to IndexMap

Open IFcoltransG opened this issue 3 years ago • 1 comments

For my usecase, I need to be able to refer to IndexMap keys by usize index as well as by their keys. Specifically, I would like access to the .insert_full(k, v) method and the Index<usize> trait implemented, from the upstream non-heapless IndexMap. Otherwise I'm better off using a plain Vec and doing linear searches, so that I can use both keys and fast usize indexing.

One alternative to the above would be Entry's .index() and IndexMap's .get_index(i) methods, which would also allow me to save the index of a key when I insert it, then read from it later.

IFcoltransG avatar Nov 20 '22 06:11 IFcoltransG

Hi, if you can port the upstream methods in to heapless I think this should be fine.

korken89 avatar Jan 10 '23 08:01 korken89