Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using treemap

Status
Not open for further replies.

lowbk

Technical User
Nov 26, 2001
162
SG
suppose i have a method that puts value into a hashtable

public void methodname(Hashtable h)
{
Hashtable h = new Hashtable()

h.put(...,...)
h.put(...,...)
h.put(...,...)

System.out.println(h.get(...).toString());
}

is it possible that to change the method such that it inserts to a TreeMap, all i need is to change Hashtable to TreeMap and the remaining code remains as it is? ie

public void methodname(TreeMap h)
{
TreeMap h = new TreeMap()

h.put(...,...)
h.put(...,...)
h.put(...,...)

System.out.println(h.get(...).toString());

}


if this is so, then we can all thank Sun for making life so easy for us.
 
i just tried it, it really works. java is so good, we must give Sun the credit.

forgive me if i sound greedy, is there anymore of such data structure implemention meant for searching? i am looking for a data structure that allows very fast searching (eg hashing, Btree)
so far, i see hashtable, red-black tree.
is there heap, B-tree, interpolation search, AVL tree, splay tree etc?

any kind soul, pls advise
 
These exist but not as part of the sun Collection libraries. You could probably find some source code by doing a search on Google.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top