Re: [External] : Re: Generalizing binary search

2024-05-16 Thread Pavel Rappo
Since you replied to my message rather than to David's, I assume you had seen the [issue] I linked. Masquerading an arbitrary binary search as a binary search on a list -- a random access list, as Louis noted correctly -- can do something for you: class Element implements Comparable {

Re: Generalizing binary search

2024-05-15 Thread Louis Wasserman
If you forget to implement RandomAccess, you'll get a very subtle performance bug. Just because it's easy if you know how to do it doesn't make it easy for a random developer to do correctly. On Wed, May 15, 2024 at 3:21 PM Mateusz Romanowski < romanowski.mate...@gmail.com> wrote: > Hi, > I

Re: Generalizing binary search

2024-05-15 Thread Mateusz Romanowski
Hi, I would say it is not worth any effort. One can easily write an ad-hoc *local* adapter extending `java.util.AbstractList`.. .. and immediately invoke existing `java.util.Collections::binarySearch` method. Cheers, MR On Thu, Apr 25, 2024 at 9:09 PM Pavel Rappo wrote: > > > > On 25 Apr

Re: Generalizing binary search

2024-04-25 Thread David Lloyd
On Thu, Apr 25, 2024 at 2:09 PM Pavel Rappo wrote: > > > > On 25 Apr 2024, at 19:41, David Lloyd wrote: > > > > The JDK contains a few collection- and array-oriented implementations of > binary search. For the most part, they all work the same way: search the > target "thing" by index using the

Re: Generalizing binary search

2024-04-25 Thread Pavel Rappo
> On 25 Apr 2024, at 19:41, David Lloyd wrote: > > The JDK contains a few collection- and array-oriented implementations of > binary search. For the most part, they all work the same way: search the > target "thing" by index using the obvious bisection strategy, returning > either /index/

Generalizing binary search

2024-04-25 Thread David Lloyd
The JDK contains a few collection- and array-oriented implementations of binary search. For the most part, they all work the same way: search the target "thing" by index using the obvious bisection strategy, returning either /index/ or /-index-1/ depending on whether it was found at the end of the