[Q]uestions regarding collections

Bob Arning arning at charm.net
Sun Aug 19 01:30:40 UTC 2001


On Sat, 18 Aug 2001 18:11:16 -0600 Jon Hylands <jon at huv.com> wrote:
>On Sat, 18 Aug 2001 21:59:35 +0200, "Raymond Tiefenthal"
><r.tiefenthal at gmx.de> wrote:
>
>> 3. I was asking myself, why SortedCollection doesn't overwrite # indexOf:
>> for instance, in order to perform a binary search.
>
>In order to do a binary search, you have to know whether the collection is
>sorted ascending or descending.
>
>Without knowing what the sort block does, I can't see how the collection
>could figure out which way to go after the first comparison...

It's not that hard, I think. A few probes, say at 1 and N, should tell you which way the collection was ordered. From then it would be an ordinary binary search.

Cheers,
Bob




More information about the Squeak-dev mailing list