/*
 * Copyright (C) 2015 Pedro Vicente Gomez Sanchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.pedrovgs.lynx.presenter;

import com.github.pedrovgs.lynx.model.Trace;
import java.util.List;

/**
 * Buffer created to keep a max number of traces and be able to configure the size of the buffer.
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
class TraceBuffer {
  public void add(List<Trace> traces) {

  }

  public List<Trace> getTraces() {
    return null;
  }
}

@@ -696,16 +696,45 @@
 .Trace;%0A
+import java.util.LinkedList;%0A
 import j
@@ -922,105 +922,872 @@
 r %7B%0A
-  public void add(List%3CTrace%3E traces) %7B%0A%0A  %7D%0A%0A  public List%3CTrace%3E getTraces() %7B%0A    return null;
+%0A  private final int bufferSize;%0A  private final List%3CTrace%3E traces;%0A%0A  TraceBuffer(int bufferSize) %7B%0A    this.bufferSize = bufferSize;%0A    traces = new LinkedList%3CTrace%3E();%0A  %7D%0A%0A  /**%0A   * Add a list of traces to the buffer, if the buffer is full your new traces will be added and%0A   * the previous one will be removed.%0A   */%0A  public void add(List%3CTrace%3E traces) %7B%0A    this.traces.addAll(traces);%0A    int tracesToDiscard = getNumberOfTracesToDiscard();%0A    if (tracesToDiscard %3E 0) %7B%0A      discardTraces(tracesToDiscard);%0A    %7D%0A  %7D%0A%0A  public List%3CTrace%3E getTraces() %7B%0A    return traces;%0A  %7D%0A%0A  private int getNumberOfTracesToDiscard() %7B%0A    int currentTracesSize = this.traces.size();%0A    return currentTracesSize - bufferSize;%0A  %7D%0A%0A  private void discardTraces(int tracesToDiscard) %7B%0A    for (int i = 0; i %3C tracesToDiscard; i++) %7B%0A      traces.remove(0);%0A    %7D
 %0A  %7D

Add implementation TraceBuffer