I'm new to hash table and I'm just figuring out the basic operations on it. I have a hash table created as shown below and inserted values also.
Hashtable<Integer , String> ht = new Hashtable<Integer , String>();
ht.put(1234, "ABCD");
ht.put(2345, "EFGH");
ht.put(4567, "IJKL");
I am able to delete the element needed using the key as shown below
System.out.println("Deleting entry with key 2345");
ht.remove(2345);
System.out.println(ht.toString());
which gives the following output
Deleting entry with key 2345
{4567=IJKL, 1234=ABCD}
I am not able to find any method which helps with locating the element in the hashtable using the value as an index and deleting the element. How do I go about it?
Mapis to access entries by key, not value. Some libraries (Guava for instance) do have bidirectional maps, but removing a key given a value is not aMap's "simple operation" ;)