indexmap-rs / indexmap

A hash table with consistent order and fast iteration; access items by key or sequence index
https://docs.rs/indexmap/
Other
1.67k stars 150 forks source link

Request: Random access of key/value pairs #338

Closed travis-leith closed 3 weeks ago

travis-leith commented 3 weeks ago

Right now I can either index keys or index values. I cannot (as far as I can tell) index (key, value) pairs.

I would like map[usize] -> (key, value).

The workaround is to convert my IndexMap<Key, Value> to IndexMap<Key, (Key, Value>> which is not ideal.

bluss commented 3 weeks ago

I think you can in fact do that, the methods for that are here (3 methods) https://docs.rs/indexmap/latest/indexmap/map/struct.IndexMap.html#method.get_index

travis-leith commented 3 weeks ago

No idea how I missed that. I will test it before closing. Thanks.