com.go.trove.util
Class SortedArrayList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--com.go.trove.util.SortedArrayList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class SortedArrayList
extends java.util.ArrayList

An extension of ArrayList that insures that all of the items added are sorted. A binary search method has been added to provide a quick way to auto sort this Collection. The method call for this search has been made public so that this Collection can be searched. Note: Not all methods for adding and removing elements are supported.

Version:
 
Author:
Sean T. Treat
See Also:
Collection, List, 5 , 5/04/01 , Serialized Form

Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SortedArrayList()
           
SortedArrayList(java.util.Collection c)
           
SortedArrayList(java.util.Comparator c)
          Constructs a new SortedArrayList.
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object o)
          Adds an Object to this Collection.
 boolean addAll(java.util.Collection c)
          Add all of the elements in the c to this List.
 boolean addAll(int index, java.util.Collection c)
           
 java.util.Comparator comparator()
           
 int findInsertionPoint(java.lang.Object o)
          Finds the index at which o should be inserted.
 java.lang.Object lastElement()
          Retrieves the last element in this List.
 java.lang.Object set(int index, java.lang.Object element)
           
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, 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
 

Constructor Detail

SortedArrayList

public SortedArrayList(java.util.Comparator c)
Constructs a new SortedArrayList. To guarantee that this Collection is properly sorted, this constructor should be called.
Parameters:
c - The comparator to use when sorting this Collection.

SortedArrayList

public SortedArrayList()

SortedArrayList

public SortedArrayList(java.util.Collection c)
Method Detail

comparator

public java.util.Comparator comparator()
Returns:
the Comparator that has been assigned to this Collection.

add

public boolean add(java.lang.Object o)
Adds an Object to this Collection.
Overrides:
add in class java.util.ArrayList
Parameters:
o - The Object to be added.
Returns:
true if this Collection is modified as a result of this call.

addAll

public boolean addAll(java.util.Collection c)
Add all of the elements in the c to this List.
Overrides:
addAll in class java.util.ArrayList
Parameters:
c - The Collection that is to be added.
Returns:
true if this Collection is altered. Otherwise, false.

lastElement

public java.lang.Object lastElement()
                             throws java.util.NoSuchElementException
Retrieves the last element in this List.
Throws:
Thrown - if this List is empty.

findInsertionPoint

public int findInsertionPoint(java.lang.Object o)
Finds the index at which o should be inserted.
Parameters:
o - The Object that is to be inserted.
Returns:
The index where Object o should be inserted.

add

public void add(int index,
                java.lang.Object element)
Overrides:
add in class java.util.ArrayList
Throws:
This - method not supported.

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Overrides:
set in class java.util.ArrayList
Throws:
This - method not supported.

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Overrides:
addAll in class java.util.ArrayList
Throws:
This - method not supported.