[jdom-interest] Attributes as HashMap?

Nianwei Liu nianweiliu at ameritech.net
Tue Oct 3 14:27:03 PDT 2000


Hi all,

  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)?
  For examaple: 

public class Element {
 ...
    HashMap attibutes;
  ...
   public void setAttribute(String name, String value) 
      {  attributes.put(name,value);}
   public String getAttributeValue(String name)
      {  return (String) (attributes.get(name)); }
}

if use HashMap, will it be faster since we do not use a iterator of the LinkedList to retrieve the Attribute then call getValue() method? or it does not matter because HashMap has to internally iterate anyway? (constant-time performence for get/put operation)

It looks like the  org.jdom.Attribute class is similar to java.util.Map.Entry,  it has two basic method getKey(), getValue(), which is same with the Attibute class. 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20001003/905f681b/attachment.htm


More information about the jdom-interest mailing list