// Copyright 2012 Georg-August-Universität Göttingen, Germany // // 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 de.ugoe.cs.autoquest.usageprofiles; import java.util.LinkedList; import java.util.List; /** *
* Implements a round-trip buffered memory of a specified length that can be used to remember the * recent history. Every event that happend longer ago than the length of the memory is forgotten, * hence the memory is incomplete. *
* * @author Steffen Herbold * @version 1.0 * * @param* Maximum length of the memory. *
*/ private int length; /** ** Internal storage of the history. *
*/ private List* Constructor. Creates a new IncompleteMemory. *
* * @param length * number of recent events that are remembered * @throws IllegalArgumentException * This exception is thrown if the length is smaller than 1 */ public IncompleteMemory(int length) { if (length < 1) { throw new IllegalArgumentException("Length of IncompleteMemory must be at least 1."); } this.length = length; history = new LinkedList* Returns the current length of the memory. This can be less than {@link #length}, if the * overall history is less than {@link #length}. *
* * @return length of the current memory */ public int getLength() { return history.size(); } }