mk.fsgrep.util
Class MRUList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<java.lang.String>
                  extended by mk.fsgrep.util.MRUList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.String>, java.util.Collection<java.lang.String>, java.util.List<java.lang.String>, java.util.Queue<java.lang.String>

public class MRUList
extends java.util.LinkedList<java.lang.String>

Most recently used list. A list ordered by recent use where the first element is the most recently used entry. It also trims itself to a maximum size.

Author:
Murali Krishnan
See Also:
Serialized Form

Field Summary
static int MAX_SIZE
          The maximum number of recent items kept when saved.
protected static java.lang.String UNDEFINED_PREFIX
          Constant representing an undefined persistent map prefix (the default).
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
MRUList()
           
MRUList(int pSize, java.lang.String pPrefix)
           
MRUList(java.lang.String pPrefix)
           
 
Method Summary
 boolean add(java.lang.String entry)
           
 int getMaxSize()
           
protected  java.lang.String getPrefix()
           
 void keepFirst()
          Remove all items except the first one.
 void readData()
          Read the stored profiles from the persistent data.
 void readData(java.lang.String pPrefix)
          Read the stored profiles from the persistent data using the given persistent map prefix.
 void saveData()
          Saves the state of this object to the persistent store.
 void setMaxSize(int val)
           
protected  void trim()
          Trim the number of entries to the maximum size by removing the older elements.
 
Methods inherited from class java.util.LinkedList
add, addAll, addAll, addFirst, addLast, clear, clone, contains, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, peek, poll, remove, remove, remove, removeFirst, removeLast, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Field Detail

MAX_SIZE

public static final int MAX_SIZE
The maximum number of recent items kept when saved.

See Also:
Constant Field Values

UNDEFINED_PREFIX

protected static final java.lang.String UNDEFINED_PREFIX
Constant representing an undefined persistent map prefix (the default).

See Also:
Constant Field Values
Constructor Detail

MRUList

public MRUList()

MRUList

public MRUList(java.lang.String pPrefix)

MRUList

public MRUList(int pSize,
               java.lang.String pPrefix)
Method Detail

getMaxSize

public int getMaxSize()

getPrefix

protected java.lang.String getPrefix()

setMaxSize

public void setMaxSize(int val)

trim

protected void trim()
Trim the number of entries to the maximum size by removing the older elements.


saveData

public void saveData()
Saves the state of this object to the persistent store.


readData

public void readData(java.lang.String pPrefix)
Read the stored profiles from the persistent data using the given persistent map prefix.

Parameters:
pPrefix - The string prefix of the desired entries.

readData

public void readData()
Read the stored profiles from the persistent data. This will only work if a persistent map prefix was defined.


keepFirst

public void keepFirst()
Remove all items except the first one.


add

public boolean add(java.lang.String entry)
Specified by:
add in interface java.util.Collection<java.lang.String>
Specified by:
add in interface java.util.List<java.lang.String>
Overrides:
add in class java.util.LinkedList<java.lang.String>


Copyright © 2009. All Rights Reserved.