Still that doesn't explain why you can't use both.  The vector would be a
vector of hashtables, oredered by the name attribute.  You could keep a
separate hashtable for quick lookups on the other hashtables.  Think of the
hashtable as an index on your data.  Hashtables are an optimization for
lookup.  You could always emulate the lookup of a hashtable using a vector
and linear search.  If you don't need to optimize lookup for speed, then
you could just stick with the vector and do linear searching.

Bill






Darren Houle <[EMAIL PROTECTED]> on 03/23/99 11:04:17 AM

Please respond to "A mailing list for discussion about Sun Microsystem's
      Java              Servlet API Technology."
      <[EMAIL PROTECTED]>



 To:      [EMAIL PROTECTED]

 cc:      (bcc: Bill Kayser/Worldstreet)



 Subject: Re: Java Question









I actually tried using a vector as you suggest just a while ago and it
works the way I need.  I cannot use just a vector as my data is too complex
for a single dimensional storage object, I'm using a master hashtable that
has names as keys and sub-hashtables as values, the sub-hashtables have
attributes as keys and vectors as values, the vectors are lists of values
that go with each attribute.  I needed a way to pull out the top level
last_name keys in alpha order and using a vector in parallel with the
master hashtable seems to work fine.

Thanks again,
Darren

>>> "Robert A. Crawford" <[EMAIL PROTECTED]> 03/23 10:45 AM
Hashtables are not ordered -- in fact, they very specifically
"mix" the order to make it possible to retrieve the element very
quickly. Find a good book on data structures for more information.  The
simple way to fix this is to use a Vector -- they're
ordered. Either slip the last name into the Vector as you're loading,
then step through the Vector and use the last name as a key into the
Hashtable, or just put everything into the Vector and use it
directly....

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to