Code example for AtomicInteger

Methods: incrementAndGet

0
     *  @return count after increment 
     */ 
    public int increment(K h) {
        AtomicInteger i = this.map.putIfAbsent(h, new AtomicInteger(1));
        if (i != null)
            return i.incrementAndGet();
        return 1; 
    } 
 
    /** 
     *  @return current count 
     */ 
    public int count(K h) {
        AtomicInteger i = this.map.get(h);
        if (i != null)
            return i.get();
        return 0; 
    } 
 
    /** 
     *  @return set of objects with counts > 0