jimmc.util
Class LimitedList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--jimmc.util.LimitedList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class LimitedList
extends java.util.ArrayList

A list with a limited size. When an item is appended to the list past the limit size, an item from the start of the list is removed to maintain the list size. NOTE: Only the addLimited(Object) method currently implements the limit checking.

See Also:
Serialized Form

Field Summary
protected  int limit
          The current maximum size of the list.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LimitedList(int initialLimit)
          Create a LimitedList.
 
Method Summary
 void addLimited(java.lang.Object obj)
          Add an element to the list.
 int getLimit()
          Get the current maximum size of the list.
 void setLimit(int limit)
          Set the maximum size of the list.
 void truncate(int position)
          Remove all items from the specified position, inclusive, to the end of the list.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, 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, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

limit

protected int limit
The current maximum size of the list.
Constructor Detail

LimitedList

public LimitedList(int initialLimit)
Create a LimitedList.
Parameters:
initialLimit - The initial capacity and limit.
Method Detail

setLimit

public void setLimit(int limit)
Set the maximum size of the list.

getLimit

public int getLimit()
Get the current maximum size of the list.

addLimited

public void addLimited(java.lang.Object obj)
Add an element to the list.

truncate

public void truncate(int position)
Remove all items from the specified position, inclusive, to the end of the list.