Since we're talking Map, I think a more utility would be gained by
including putIfAbsent (see java.util.concurrent) because I see many
lines of code that do that idiom all the time.

This idiom is especially prevalent when the value is itself a nested collection.

Map<Object, List<Object>> map = ...
List<Object> collection = map.get(key);
if (collection == null) {
  collection = new LinkedList<Object>();
  map.put(key, collection);
}
collection.add(value);

Paul

Reply via email to