Get index of key-value pair in OrderedMap
See original GitHub issueIs your feature request related to a problem? Please describe.
I have such problem: I want to know how much values are between of two keys.
I have a timeline of thousands of events, and I use an OrderedMap (key is timestamp, value — event data), because I draw a line chart for them. I want to give a user an opportunity to know, how many events are between two chosen points.
Describe the solution you’d like If I’d have an index of an item, I could do this:
// eventMap is an OrderedMap
const leftIndex = eventMap.getIndexByKey(leftKey)
const rightIndex = eventMap.getIndexByKey(rightKey)
const eventsBetween = rightIndex - leftIndex - 1
Describe alternatives you’ve considered
I could also have a simple method like OrderedMap.prototype.itemsBetweenKeys
:
// eventMap is an OrderedMap
const eventsBetween = eventMap.itemsBetweenKeys(leftKey, rightKey)
Issue Analytics
- State:
- Created a year ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Get index of element in C++ map - Stack Overflow
To access an index i of your map, use yourMap[keys[i]] . This is also O(1) and significantly faster because it's using only an...
Read more >unordered_map at() in C++ - GeeksforGeeks
Unordered_map : unordered_map is an associated container that stores elements formed by the combination of key value and a mapped value.
Read more >std::unordered_map::find - CPlusPlus.com
An iterator to the element, if the specified key value is found, or unordered_map::end if the specified key is not found in the...
Read more >unordered_map c++ - Everything you Need to know
The unordered_map in C++ is like a data structure of dictionary type that store element. It has a sequence of (key, value) pair,...
Read more >std::unordered_map - cppreference.com
Unordered map is an associative container that contains key-value pairs with unique keys. Search, insertion, and removal of elements have ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, there’s a bug.
See https://github.com/js-sdsl/js-sdsl/issues/47.
We will fix it soon.
New version 4.1.5-beta.0 has been published with
index
enabled.We will release the official version next week if no bug reports.