What are some of the benefits of using a hash table data structure?
benefits of hash code
Collapse
This topic is closed.
X
X
-
jovaTags: None -
Kevin Nuckolls
Re: benefits of hash code
jova wrote:[color=blue]
> What are some of the benefits of using a hash table data structure?
>
>[/color]
I found hashtables to be very useful when needing to sort through a
large set of classes. Each class has a name property, when i add a class
to the hashtable i do something like:
Hashtable table = new Hashtable();
Human newHuman = new Human();
newHuman.setNam e("Carl");
table.put(newHu man.getName(),n ewHuman);
thus, i can sort the hashtable by each Human's name.
anyway, once the hashtable is populated, i can easily search the table
with the containsKey() method, to see if a Human is in this table.
That's all i normally use it for, massive class searching by name.
Comment