public T add(T e){
  T oldE=null;
  while (!buffer.offerLast(e)) {
    oldE=buffer.poll();
  }
  return oldE;
}

public T add ( T e ) { T oldE = null ; while ( ! buffer . offerLast ( e ) ) { oldE = buffer . poll ( ) ; } return oldE ; }
adding an element to the circular buffer implies adding the element to the tail of the deque . in doing so , if the capacity of the buffer has been exhausted , then the deque ' s head should be removed to preserve the circular nature of the buffer . a linkedblockingdeque is used because of its concurrent nature and the fact that adding to tail and removing from head are both o ( 1 ) operations . the removed head is returned to the caller for reuse .
