You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering how SortedSet can help achieve the same functionality that Java TreeSet implementing ceiling/floor method? Let's take ceiling for example, it accepts a object as parameter, and tries to find if the current set has a matching element first. If the element exists in set, then return; otherwise, return the next element in the set that is larger than this parameter. If it exists return, otherwise return null.
In Java, since it's using a red-black tree, it can utilise the balancing property to find out this ceiling/floor value very efficiently. However, in Ruby I've no idea how to do it effectively. Would appreciate if you can share any thoughts/comments on this. Many thanks!
The text was updated successfully, but these errors were encountered:
of course, these methods would ideally be exposed by sorted_set, just as rbtrees efficient #first and #last methods should be exposed through overrides of #min, #max and #minmax, which currently fall back to the inefficient implementation from the included Enumerable module.
Hi,
I was wondering how SortedSet can help achieve the same functionality that Java TreeSet implementing ceiling/floor method? Let's take ceiling for example, it accepts a object as parameter, and tries to find if the current set has a matching element first. If the element exists in set, then return; otherwise, return the next element in the set that is larger than this parameter. If it exists return, otherwise return null.
Below are some test cases.
In Java, since it's using a red-black tree, it can utilise the balancing property to find out this ceiling/floor value very efficiently. However, in Ruby I've no idea how to do it effectively. Would appreciate if you can share any thoughts/comments on this. Many thanks!
The text was updated successfully, but these errors were encountered: