[jdom-interest] Attributes as HashMap?

Alex Chaffee guru at edamame.stinky.com
Fri Oct 6 18:47:35 PDT 2000

> http://developer.java.sun.com/developer/bugParade/bugs/4187872.html
> LinkedHashMap gives the nice benefit that attribute order is
> maintained (iteration order is insertion order) and access happens in
> O(1). Of course, incorporating LinkedHashMap.java results in an
> unacceptable code bloat, and alternatively maintaining both a linked
> list *AND* a hash map manually does not necessarily improve
> performance. Again, benchmarks would help to find the break even.
> -Oliver

Cool! I didn't know that. I've amended the jGuru Collection FAQ at

Why would it involve code bloat?  I'm stalled out trying to download
the source so I can't see if it depends on anything else.  In any
case, we can't include Sun code in JDOM, so even if it has no
dependencies, we couldn't make it available for JDK <= 1.2 use.

In any case, if anyone wants, I've got open-source code (linked in the
FAQ above) that does almost the same thing.  One could write
getAttributeMap() fairly easily by calling

  List ordered = new EntryList(attributes);
  return ordered.asMap();

though I leave the details as an exercise to the reader :-)

 - A

Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/

More information about the jdom-interest mailing list