[jdom-interest] HashMap/HashSet for attributes/childs

Christophe D. Laprun chris.laprun at nist.gov
Fri Aug 18 11:29:19 PDT 2000

Jason Hunter wrote:
> For attributes this would make more sense.  I think it's done this way
> because by using a List attribute order is preserved, not something
> that's needed by XML but something that makes round-tripping possible.
> And considering most elements have 1 attrib and at most 3 it's not a
> large performance penalty either.

How about SortedMap using a specific object as key and not Strings ?
Using a specific object would have the benefit of being able to delegate
the comparison to a sorting component (possibly changed at runtime when
a different sorting logic is needed, I am not sure if it is possible
since I am not sure if sorting on SortedMaps is done at insertion time
or iteration time) and being also able to have a better hashcode
function (or at least cache the hashcode of the underlying String since
String re-computes its hashcode each time making it rather inefficient
for use in Maps).

Just my 2 cents... I agree that performance should only be a concern
when the API is stable and working.

Christophe Laprun    [Ingenieur ISIMA, France / Guest researcher @NIST]
web: http://www.nist.gov/speech/staff/laprunch.htm
email: chris.laprun at nist.gov
phone: (301) 975 3191             fax: (301) 670 0939
The universe seems neither benign nor hostile, merely indifferent -

More information about the jdom-interest mailing list