Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "Mike Schilling" Newsgroups: comp.lang.java.programmer Subject: Re: Binary Search Date: Sat, 2 Apr 2011 07:58:39 -0700 Organization: A noiseless patient Spider Lines: 2 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 8bit Injection-Date: Sat, 2 Apr 2011 14:58:11 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="nPgGKe3051Y3NHz75zStxg"; logging-data="958"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ez561JuxYoSCygdLA/6NkEPOTe5iOkzA=" X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416 In-Reply-To: X-Newsreader: Microsoft Windows Live Mail 14.0.8117.416 Importance: Normal Cancel-Lock: sha1:e/S1E6PFDZrgsS0g/D9Qw7i8rGI= X-Priority: 3 X-MSMail-Priority: Normal Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2756 "Lawrence D'Oliveiro" wrote in message news:in6oj8$5b5$3@lust.ihug.co.nz... > In message , Mike Schilling wrote: > >> "Lawrence D'Oliveiro" wrote in message >> news:imouja$56s$2@lust.ihug.co.nz... >> >>> In message , Roedy Green >>> wrote: >>> >>>> The problem is, Map and SortedMap don't "map" well onto binary search. >>>> binary search to work properly requires embedded keys. Maps require >>>> them separate. >>> >>> Sounds like the Java Map classes are not well designed. >> >> Or that someone doesn't understand them. Embedded keys can be made to >> work perfectly well with SortedMaps simply by making both arguments to >> put() the same, and providing a comparator that can locate the key in the >> object. > > So why isn’t there a single-argument overload of the put method to save > you > the trouble? There is, if you use a Set instead of a Map. Which, for sorting, works equally well.