public static <A> void addCount(A a, Map<A, AtomicInteger> counts) {
        AtomicInteger count = counts.get(a);
        if (count == null) {
            count = new AtomicInteger(1);
            counts.put(a, count);
        } else {
            count.incrementAndGet();
        }
    }