Code example for LinkedHashSet

Methods: add

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();
  }