Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.google.sitebricks.util;
 
 
 import java.util.List;
 import java.util.Queue;
Adds elements to a list, will remove oldest items if the maximum specified capacity is exceeded. TheadSafe & concurrent.
public class BoundedDiscardingList<E> {
  private final Queue<E> queue = new ConcurrentLinkedQueue<E>();
  private final int maxlength;
  public BoundedDiscardingList(int maxlength) {
    this. = maxlength;
  }
  public boolean add(E item) {
    .add(item);
    if (.size() > ) {
      .poll();
    }
    return true;
  }

  
Returns a snapshot of the list at *some* point in time.
  public List<E> list() {
    return Lists.newArrayList();
  }
New to GrepCode? Check out our FAQ X