[jdom-interest] Attributes as HashMap?

Oliver Imbusch flabes at livis.de
Fri Oct 6 17:50:33 PDT 2000

>>>>> "jh" == Jason Hunter <jhunter at collab.net> writes:

    >   I have a general question:
    >   Is there particular reason why choose a LinkedList as attributes in
    > Element, not use a HashMap directly, even an attribute is a name-value
    > pair (as in the java.util.Map)?

Ah, here we go again.

    jh> As Alex said, a list is probably

Do we have benchmarks for JDOM? Some numbers would improve the
discussion on that subject.

    jh> equivalent or better performance than a map until you have
    jh> many attributes,

Access, insertion, removal, iteration? How many attributes?

    jh> and a list gives the nice benefit that attribute order is
    jh> maintained (not required but human-friendly).


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.


More information about the jdom-interest mailing list