Code example for LinkedHashSet

Methods: addremove

0
    this.evictionOrder = new LinkedHashSet<Integer>();
  } 
     
  public void add(int page)
  { 
    evictionOrder.add(page);
  } 
  public void remove(int page)
  { 
    evictionOrder.remove(page);
  } 
  public void touch(int page)
  { 
    remove(page); add(page);
  } 
  public int selectCandidate() 
  { 
    if(evictionOrder.size() == 0){ return -1; }
    return evictionOrder.iterator().next();
  } 
Experience pair programming with AI  Get Codota for Java