Ignore:
Timestamp:
07/05/11 15:18:56 (13 years ago)
Author:
sherbold
Message:
  • code documentation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IncompleteMemory.java

    r19 r106  
    44import java.util.List; 
    55 
     6/** 
     7 * <p> 
     8 * Implements a round-trip buffered memory of a specified length that can be 
     9 * used to remember the recent history. Every event that happend longer ago than 
     10 * the length of the memory is forgotten, hence the memory is incomplete. 
     11 * </p> 
     12 *  
     13 * @author Steffen Herbold 
     14 * @version 1.0 
     15 *  
     16 * @param <T> 
     17 *            Type which is memorized. 
     18 */ 
    619public class IncompleteMemory<T> implements IMemory<T> { 
    720 
     21        /** 
     22         * <p> 
     23         * Maximum length of the memory. 
     24         * </p> 
     25         */ 
    826        private int length; 
    9          
     27 
     28        /** 
     29         * <p> 
     30         * Internal storage of the history. 
     31         * </p> 
     32         */ 
    1033        private List<T> history; 
    11          
     34 
     35        /** 
     36         * <p> 
     37         * Constructor. Creates a new IncompleteMemory. 
     38         * </p> 
     39         *  
     40         * @param length 
     41         *            number of recent events that are remembered 
     42         */ 
    1243        public IncompleteMemory(int length) { 
    1344                this.length = length; 
    1445                history = new LinkedList<T>(); 
    1546        } 
    16          
     47 
     48        /* 
     49         * (non-Javadoc) 
     50         *  
     51         * @see de.ugoe.cs.eventbench.models.IMemory#add(java.lang.Object) 
     52         */ 
    1753        @Override 
    1854        public void add(T state) { 
    19                 if( history.size()==length ) { 
     55                if (history.size() == length) { 
    2056                        history.remove(0); 
    2157                } 
     
    2359        } 
    2460 
     61        /* 
     62         * (non-Javadoc) 
     63         *  
     64         * @see de.ugoe.cs.eventbench.models.IMemory#getLast(int) 
     65         */ 
    2566        @Override 
    2667        public List<T> getLast(int num) { 
     
    2869        } 
    2970 
     71        /** 
     72         * <p> 
     73         * Returns the current length of the memory. This can be less than 
     74         * {@link #length}, if the overall history is less than {@link #length}. 
     75         * </p> 
     76         *  
     77         * @return length of the current memory 
     78         */ 
    3079        public int getLength() { 
    3180                return history.size(); 
Note: See TracChangeset for help on using the changeset viewer.