public boolean remove(Object o) { boolean ret = entries.remove(o); times.remove(o); if(ret) checkStale(); return ret; }
public boolean add(E e, long leasetime) { times.put(e, getExpirationTime(leasetime)); boolean ret = entries.add(e); //if(ret) checkStale(); return ret; }
public boolean addAll(Collection<? extends E> c) { boolean changed = false; for(E entry: c) { changed |= add(entry); } if(changed) checkStale(); return changed; }
public boolean removeAll(Collection<?> c) { boolean changed = false; for(Object entry: c) { changed |= remove(entry); } if(changed) checkStale(); return changed; }
/** * Update the timestamp of e. * @param entry The entry. */ public void touch(E e, long leasetime) { times.put(e, getExpirationTime(leasetime)); // Does only reorder when element is added again :-( // http://stackoverflow.com/questions/6952660/java-priority-queue-reordering-when-editing-elements entries.remove(e); entries.add(e); checkStale(); }
public boolean retainAll(Collection<?> c) { // return entries.retainAll(c); boolean changed = false; for(E e: entries.toArray((E[])new Object[entries.size()])) { if(!c.contains(e)) { changed = true; remove(e); } } if(changed) checkStale(); return changed; }