I tend to use the map in an immutable, single-linked list, usually calling it Cons for historical reasons, where the list ends with a null character. In this case, the code above comes down to:
public void addItem(K key, V value) { map.put ( key, new Cons<V> ( value, map.get ( key ) ) ); }
since a minus is created with a zero value, since its tail is valid.
source share