Lavandowska wrote:
> 
> --- Jari Worsley <[EMAIL PROTECTED]> wrote:
> > so you're using the hashtable as a convenient way of indexing into a
> > list? i.e. like a Vector/List/Whatever but with faster retrieval?
> 
> Where I see this being of use is when I have two parallel Lists that
> need to be accessed in unison.  I can use the "SequencedHashMap" as a
> container for them.  A good usage example is the Input:select taglib
> over in Jakarta Taglibs.  A Map is used for the value (Map key) and
> display (Map value) of the &lt;option&gt; tags within the Select tag.
> This effect could just as well be achieved with two Lists, or even a
> two-dimensional array (I once wrote an HTML object library using the
> latter technique, see
> http://www.brainopolis.com/jsp/javadocs/com/brainopolis/html/SelectList.html).

in other words where you have two lists to maintain, but where it isn't
a requirement that one of the lists is a Set (i.e. no duplicate values)?

so yes agree- there you either implement an object that holds the
"name-value" pair for the select taglib and use a List, or you have to
maintain separate lists for the value and display value - although if
the value is unique then you can just use a single HashMap (except as
said you then lose the ordering :(.


> 
> > Couldn't you achieve the same effect by ensuring the objects you put
> > into a Vector implement equals and hashcode in a satisfactory manner,
> > then just rely on methods like indexOf(Object ) and contains(Object
> > )?
> 
> Not to be argumentative, but I don't see how I would implement equals()
> such that it knows when an instance was placed into a Map.

yes. I'm not quite sure what I meant there myself, so ignore... :(
Although equals should always be implemented on it's own without
reference to where the object might be used. (e.g. classes like Long
compare the value rather than just the reference).

> 
> > Seems a bit weird - sequencedhashtable as a name implies to me that
> > it
> > can be in any sequence, not just the order the elements were put in.
> > Something like "KeyedList" seems slightly nearer to what it does.
> >
> > (note , I said "a bit weird", not "a lot weird"... :)
> 
> I agree, "sequenced" doesn't really give enough information.  Likewise,
> the forthcoming 1.4 class LinkedHashMap doesn't tell me anything
> (perhaps I don't understand what "Linked" means here).  I like
> (whoever's) suggestion of "InputOrderedHashMap" even if it is a bit
> wordy.

yes, LinkedHashMap doesn't say much either. oh well, i guess we'll get
used to whatever name things are given in the end. :)

Jari
--
Jari Worsley
Senior Programmer
Hyperlink Interactive Ltd

Reply via email to