net.spy.util
Class LimitedList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.AbstractSequentialList
              extended byjava.util.LinkedList
                  extended bynet.spy.util.LimitedList
All Implemented Interfaces:
Cloneable, Collection, List, Serializable

public class LimitedList
extends LinkedList

A LinkedList with a maximum capacity.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LimitedList(int l)
          Get an instance of Queue.
 
Method Summary
 void add(int index, Object o)
          Override add to enforce the limit.
 boolean add(Object o)
          Override add to enforce the limit.
 boolean addAll(Collection c)
          Override addAll to enforce the limit.
 boolean addAll(int index, Collection c)
          Override addAll to enforce the limit.
 void addFirst(Object o)
          Override addFirst to enforce the limit.
 void addLast(Object o)
          Override addLast to enforce the limit.
 int getLimit()
          Get the maximum number of elements that may be stored in this list.
 void setLimit(int to)
          Dynamically reset the limit.
 
Methods inherited from class java.util.LinkedList
clear, clone, contains, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, 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
 

Constructor Detail

LimitedList

public LimitedList(int l)
Get an instance of Queue.

Method Detail

setLimit

public void setLimit(int to)
Dynamically reset the limit. This will not have an effect on existing items, but will prevent new items from being added if the limit is exceeded.

Parameters:
to - the new limit value

getLimit

public int getLimit()
Get the maximum number of elements that may be stored in this list.


add

public void add(int index,
                Object o)
Override add to enforce the limit.

Parameters:
index - index at which to add
o - object to add
Throws:
IndexOutOfBoundsException - if the limit is exceeded (or the parent size thinks it's too big).

add

public boolean add(Object o)
Override add to enforce the limit.

Parameters:
o - object to add
Throws:
IndexOutOfBoundsException - if the limit is exceeded (or the parent size thinks it's too big).

addFirst

public void addFirst(Object o)
Override addFirst to enforce the limit.

Parameters:
o - object to add
Throws:
IndexOutOfBoundsException - if the limit is exceeded (or the parent size thinks it's too big).

addLast

public void addLast(Object o)
Override addLast to enforce the limit.

Parameters:
o - object to add
Throws:
IndexOutOfBoundsException - if the limit is exceeded (or the parent size thinks it's too big).

addAll

public boolean addAll(int index,
                      Collection c)
Override addAll to enforce the limit.

Parameters:
index - the index at which to add the collection
c - Collectoin of objects to add
Throws:
IndexOutOfBoundsException - if the limit is exceeded (or the parent size thinks it's too big).

addAll

public boolean addAll(Collection c)
Override addAll to enforce the limit.

Parameters:
c - Collectoin of objects to add
Throws:
IndexOutOfBoundsException - if the limit is exceeded (or the parent size thinks it's too big).