Code example for WeakHashMap

Methods: containsKeygetput

0
    this.max = max;
    this.initRandomly = initRandomly;
  } 
 
  public void maybeRunWith(T ob) {
    if (!counters.containsKey(ob)) {
      if (initRandomly) {
        counters.put(ob, random.nextInt(max));
      } else { 
        counters.put(ob, 0);
      } 
    } 
    int counter = (counters.get(ob) + 1) % max;
    counters.put(ob, counter);
    if (counter == 0) {
      closure.run(ob);
    } 
  } 
 
  public void forceRun(T ob) {
Experience pair programming with AI  Get Codota for Java