I'm using the google collections library from guava, I believe the most recent version.
I find that once I remove the final (K, V) pair from the map for a given value of K, the map still contains an entry for K, where V is an empty collection.
I would rather have the map not contain this entry. Why can't I remove it? Or, if I can, how?
It's probably something simple that I have missed. Here is a code example. Thanks.
// A plain ordinary map.
Map<Integer, Integer> hm = new HashMap<Integer, Integer>();
hm.put(1, 2);
hm.remove(1);
// Value of key 1 in HashMap: null
System.out.println("Value of key 1 in HashMap: " + hm.get(1));
// A list multimap.
ListMultimap<Integer, Integer> lmm = ArrayListMultimap.<Integer, Integer> create();
lmm.put(1, 2);
lmm.remove(1, 2);
// Value of key 1 in ArrayListMultiMap: []
System.out.println("Value of key 1 in ArrayListMultiMap: " + lmm.get(1));
// A set multimap.
SetMultimap<Integer, Integer> smm = HashMultimap.<Integer, Integer> create();
smm.put(1, 2);
smm.remove(1, 2);
// Value of key 1 in HashMultimap: []
System.out.println("Value of key 1 in HashMultimap: " + smm.get(1));