Java tutorial
//package com.java2s; /** * (c) Winterwell Associates Ltd, used under MIT License. This file is background IP. */ import java.util.Map; public class Main { public static <X> int plus(Map<X, Integer> counts, X key, int dx) { Integer x = counts.get(key); if (x == null) x = 0; x += dx; counts.put(key, x); return x; } }