uchicago.src.sim.util
Class ConservationCollection

java.lang.Object
  extended by uchicago.src.sim.util.ConservationCollection

public class ConservationCollection
extends java.lang.Object

A Vector like collection class that maintains a specified size by either randomly removing elements of the collection or removing elements through the Remover class. On any add operation the new objects are added and if the size of the collection is over the limit, the appropriate number of objects are then removed. Note that on a random remove objects that have just been added may be removed.

Version:
$Revision: 1.4 $ $Date: 2004/11/03 19:51:06 $
Author:
Nick Collier

Constructor Summary
ConservationCollection(int sizeLimit)
          Creates a ConservationCollection with the specified size limit.
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object o)
          Adds the specified object to the collection.
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(int index)
           
 int hashCode()
           
 int indexOf(java.lang.Object o)
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int index)
           
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 boolean retainAll(java.util.Collection c)
           
 java.lang.Object set(int index, java.lang.Object element)
           
 int size()
           
 java.util.List subList(int fromIndex, int toIndex)
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConservationCollection

public ConservationCollection(int sizeLimit)
Creates a ConservationCollection with the specified size limit.

Parameters:
sizeLimit - the size limit of this ConservationCollection.
Method Detail

add

public boolean add(java.lang.Object o)
Adds the specified object to the collection. If the addition of this object to collection puts the collection over the size limit, an object in the collection removed according to the Rmoeve

Parameters:
o - the object to add

add

public void add(int index,
                java.lang.Object element)

addAll

public boolean addAll(java.util.Collection c)

addAll

public boolean addAll(int index,
                      java.util.Collection c)

clear

public void clear()

contains

public boolean contains(java.lang.Object o)

containsAll

public boolean containsAll(java.util.Collection c)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

get

public java.lang.Object get(int index)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

indexOf

public int indexOf(java.lang.Object o)

isEmpty

public boolean isEmpty()

iterator

public java.util.Iterator iterator()

lastIndexOf

public int lastIndexOf(java.lang.Object o)

listIterator

public java.util.ListIterator listIterator()

listIterator

public java.util.ListIterator listIterator(int index)

remove

public java.lang.Object remove(int index)

remove

public boolean remove(java.lang.Object o)

removeAll

public boolean removeAll(java.util.Collection c)

retainAll

public boolean retainAll(java.util.Collection c)

set

public java.lang.Object set(int index,
                            java.lang.Object element)

size

public int size()

subList

public java.util.List subList(int fromIndex,
                              int toIndex)

toArray

public java.lang.Object[] toArray()

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)