Re: Inserting In a List
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