/** * Removes 'tail' from list and returns it. Returns null if list is empty. * @return current tail element. */ public Node unpush() { if (head == null) return null; Node nde = getTail(); remove(nde); return nde; }
/** * Removes 'tail' from list and returns it. Returns null if list is empty. * @return current tail element. */ public Node unpush() { if (head == null) return null; Node nde = getTail(); remove(nde); return nde; }
/** * Removes 'tail' from list and returns it. Returns null if list is empty. * @return current tail element. */ public Node unpush() { if (head == null) return null; Node nde = getTail(); remove(nde); return nde; }
public synchronized void setSize(int newSz) { if (maxSize < newSz) { // list grew... for (int i=maxSize; i<newSz; i++) free.add(new LRUNode()); } else if (maxSize > newSz) { for (int i=used.getSize(); i>newSz; i--) { LRUNode nde = (LRUNode)used.getTail(); used.remove(nde); nde.setObj(null); } } maxSize = newSz; }
public synchronized void setSize(int newSz) { if (maxSize < newSz) { // list grew... for (int i=maxSize; i<newSz; i++) free.add(new LRUNode()); } else if (maxSize > newSz) { for (int i=used.getSize(); i>newSz; i--) { LRUNode nde = (LRUNode)used.getTail(); used.remove(nde); nde.setObj(null); } } maxSize = newSz; }
public synchronized void setSize(int newSz) { if (maxSize < newSz) { // list grew... for (int i=maxSize; i<newSz; i++) free.add(new LRUNode()); } else if (maxSize > newSz) { for (int i=used.getSize(); i>newSz; i--) { LRUNode nde = (LRUNode)used.getTail(); used.remove(nde); nde.setObj(null); } } maxSize = newSz; }
public synchronized void add(LRUObj obj) { LRUNode nde = obj.lruGet(); // already linked in... if (nde != null) { used.touch(nde); return; } if (free.getSize() > 0) { nde = (LRUNode)free.pop(); nde.setObj(obj); used.add(nde); } else { nde = (LRUNode)used.getTail(); nde.setObj(obj); used.touch(nde); } }
public synchronized void add(LRUObj obj) { LRUNode nde = obj.lruGet(); // already linked in... if (nde != null) { used.touch(nde); return; } if (free.getSize() > 0) { nde = (LRUNode)free.pop(); nde.setObj(obj); used.add(nde); } else { nde = (LRUNode)used.getTail(); nde.setObj(obj); used.touch(nde); } }
public synchronized void add(LRUObj obj) { LRUNode nde = obj.lruGet(); // already linked in... if (nde != null) { used.touch(nde); return; } if (free.getSize() > 0) { nde = (LRUNode)free.pop(); nde.setObj(obj); used.add(nde); } else { nde = (LRUNode)used.getTail(); nde.setObj(obj); used.touch(nde); } }