class LoggingBuffer {

  public void removeBufferLinesBefore( long minTimeBoundary ) {
    // Using HashSet even though BufferLine does not implement hashcode and equals,
    // we just need to remove the exact objects we have found and put in the set.
    Set<BufferLine> linesToRemove = new HashSet<>();
    lock.writeLock().lock();
    try {
      for ( BufferLine bufferLine : buffer ) {
        if ( bufferLine.getEvent().timeStamp < minTimeBoundary ) {
          linesToRemove.add( bufferLine );
        } else {
          break;
        }
      }
      // removeAll should run fast against a HashSet,
      // since ArrayList.batchRemove check for each element of a collection given if it is in the ArrayList.
      // Thus, removeAll should run in a linear time.
      buffer.removeAll( linesToRemove );
    } finally {
      lock.writeLock().unlock();
    }
  }

  public  LoggingBuffer( int bufferSize );

}