Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: SortedMap question? Date: Sat, 24 Nov 2012 15:23:55 -0800 Organization: A noiseless patient Spider Lines: 13 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 24 Nov 2012 23:23:57 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="9b3fcb0d22708969e4dc99e7aa0ef1f9"; logging-data="18552"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UZ4uuZi9YsCV/P7jJh8YS" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 Cancel-Lock: sha1:hvhAQ5uUpBOIAfiQn3wgzpy/b0k= Xref: csiph.com comp.lang.java.programmer:19910 I have been operating under a mis-perception that a SortedMap would be more quickly searched than an unsorted Map. More specifically that the cost would come when adding an element to the SortedMap. I wrote a little test program to measure the amount of time it took to look for non-existent data in a Map and a SortedMap and it took somewhere between twice and three times as long to look for the data in the SortedMap. So am I know correct in thinking that the only real advantage of a SortedMap is if you wish to iterate over the keys of the map in some order? Thanks, knute...