In the last unit we looked at how a Hash Table is a nice alternative to other data structures that require fast access, especially when searching.
This is especially true when collisions can be avoided, which is almost impossible. However, a good hashing function can reduce the opportunity for collisions.
Collision resolution strategies such as Linear Polling and Separate Chaining can be used.
Also, when the Load Factor of a hash table passes a threshold, the table is resized with every item in the table being rehashed.
But which Abstract Data Types use Hash Tables in their implementation?
One ADT is the HashSet.
Now we know a little about subsets/supersets using the HashSet class's containsAll method.
We can also:
Set
Set
set1.addAll(set2);
Will produce a HashSet containing {"Australia", "Canada", "USA", "UK", "France"}
Set
Set
set1.retainAll(set2);
Will produce a HashSet containing {"Australia"}
Set
Set
set1.removeAll(set2);
Will produce a HashSet containing {"Canada","USA"}
object
property
method
create an object/instance of a class
instantiate an object
encapsulate
access
mutate
abstraction
idesyntax file class instantiate constructor type propertymethod