Path: csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Inserting In a List Date: Wed, 03 Apr 2013 20:50:26 -0400 Organization: A noiseless patient Spider Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 4 Apr 2013 00:48:03 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="19180"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zEOSvQP4KE0BoNY4xjmGL" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: Cancel-Lock: sha1:J+Q/sgoy0LRC5imNUKgx1sI3MIY= Xref: csiph.com comp.lang.java.programmer:23262 On 4/3/2013 6:37 PM, Martin Gregorie wrote: > On Tue, 02 Apr 2013 21:08:26 -0400, Eric Sosman wrote: > >> On 4/2/2013 6:52 PM, Martin Gregorie wrote: >>>[...] >>> I use it a lot, both for that and because accessing stored objects by >>> key from a TreeMap is almost certainly faster than scanning an ArrayMap >>> unless it contains very few objects indeed. >> >> Sorry: "ArrayMap"? >> > I meant ArrayList - my bad. Okay, I still don't understand: How does "accessing stored objects by key" pertain to an ArrayList, or to any List? You can hunt through a List to find an element equal to a search object (or having some specified relation to it), but "by key?" There's nothing in the List abstraction to distinguish "key" from "value" from "haddocks' eyes:" Something's in the List or it ain't, and that's all. For my part, I think that if you want to list a directory's content in some sorted order, the preferred approach is to form a List of the contents, paying no attention to order, and then sort it at the end. Spending extra time and memory computing intermediate results that you won't use seems pointless. YMMV. -- Eric Sosman esosman@comcast-dot-net.invalid