Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficient way to find the next smaller element than a given key in a TreeMap/TreeSet #8621

Open
scabug opened this issue May 26, 2014 · 1 comment

Comments

@scabug
Copy link

scabug commented May 26, 2014

Given a Set with elements (10,20,30,40,...) we need to find the next smallest and next largest element (both inclusive), e.g. nextSmallest(25) = 20, nextLargest(25) = 30.

Given a TreeMap this can be quickly done by traversing the tree. Sadly to achieve this in Scala 2.11 you have to copy the code of the TreeMap and RedBlack-classes.

On the other hand the next largest element can now be efficiently found using iteratorFrom introduced by #6642.

There should be a simple way to find the next smallest element, for example by introducing a reverseIteratorFrom.

@scabug
Copy link
Author

scabug commented May 26, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8621?orig=1
Reporter: Martin Großmann (mgrossmann)
Affected Versions: 2.11.0
See #6642

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@SethTisue SethTisue modified the milestones: Backlog, 3.x Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants