package de.ugoe.cs.eventbench.markov; import java.util.LinkedList; import java.util.List; public class IncompleteMemory implements IMemory { private int length; private List history; public IncompleteMemory(int length) { this.length = length; history = new LinkedList(); } @Override public void add(T state) { if( history.size()==length ) { history.remove(0); } history.add(state); } @Override public List getLast(int num) { return new LinkedList(history); // defensive copy } public int getLength() { return history.size(); } }