I'm looking for a structure which hashes keys without requiring a value. When queried, it should return true if the key is found and false otherwise. I'm looking for something similar to
Hashtable<MyClass, Boolean>
except insertion requires only a key and queries only ever return true or false, never null.
views:
511answers:
4
+2
A:
See also the static methods Collections#newSetFromMap
that creates a set based on the given map implementation. This is eg handy to create a weak hash set.
Adrian
2009-03-05 00:55:33
A:
Java Set is designed to remove duplicates and hopefully the HashMap must be using Java Set internally for managing key as keys can never have duplicates, So you should be considering set for your requirement.
Kalinga
2010-01-07 11:54:45