question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get index of key-value pair in OrderedMap

See original GitHub issue

Is 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:closed
  • Created a year ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ZLY201commented, Sep 23, 2022

@ZLY201 Thank you so much for that feature. It will make my experience of using your library so much better 🔥

Sorry, there’s a bug.

See https://github.com/js-sdsl/js-sdsl/issues/47.

We will fix it soon.

1reaction
ZLY201commented, Sep 23, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found