示例#1
0
 @Override
 public boolean retainAll(Collection<?> arg0) {
   boolean removed = true;
   List<TimeWrapped> removals = new ArrayList<TimeWrapped>();
   for (TimeWrapped item : queue) {
     boolean toRemove = true;
     for (Object keeper : arg0) toRemove &= !item.equals(keeper);
     if (toRemove) removals.add(item);
   }
   for (TimeWrapped item : removals) removed &= remove(item);
   return removed;
 }
示例#2
0
 private boolean add(TimeWrapped arg0) {
   pruneToDuration();
   if (arg0.getWrapped() == null) return false;
   if (queue.size() >= capacity) {
     try {
       ((CapacityOverflowHandler<T>) continuation)
           .handleCapacityOverflow(queue.remove().getWrapped());
     } catch (NullPointerException e) {
       queue.remove();
     } catch (ClassCastException e) {
       queue.remove();
     }
   }
   increment(arg0.getWrapped());
   return queue.add(arg0);
 }