eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class SortedArrayList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--mss.ea.core.SortedArrayList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class SortedArrayList
extends java.util.ArrayList

Sorted array list. This implementation of an array list guarantees, that all contained elements are sorted. The elements must implement the interface Comparable or a Comparator must be given with the method setComparator().

Since:
0.1
Version:
0.1 (06-20-2001)
Author:
Andreas Rummler
See Also:
Serialized Form

Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SortedArrayList()
           
SortedArrayList(java.util.Collection c)
           
SortedArrayList(int initialCapacity)
           
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object element)
           
 void add(java.lang.Object[] array)
          Inserts an array into the array list.
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
protected  int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two elements.
protected  int insert(java.lang.Object c)
          Inserts a new element.
 void removeRangeRange(int fromIndex, int toIndex)
          Deletes a range in the array list.
 java.lang.Object search(java.lang.Object o)
          Performs a binary search on the sorted array list.
 java.lang.Object set(int index, java.lang.Object obj)
           
 void setComparator(java.util.Comparator c)
          Sets a new comparator.
 
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()

SortedArrayList

public SortedArrayList(java.util.Collection c)

SortedArrayList

public SortedArrayList(int initialCapacity)
Method Detail

add

public boolean add(java.lang.Object element)
Overrides:
add in class java.util.ArrayList

add

public void add(int index,
                java.lang.Object element)
Overrides:
add in class java.util.ArrayList

addAll

public boolean addAll(java.util.Collection c)
Overrides:
addAll in class java.util.ArrayList

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Overrides:
addAll in class java.util.ArrayList

set

public java.lang.Object set(int index,
                            java.lang.Object obj)
Overrides:
set in class java.util.ArrayList

insert

protected int insert(java.lang.Object c)
Inserts a new element. This is the only possibility to insert a new element. This is necessary to guarantee that the elements are sorted. All overloaded methods use this method.
Parameters:
c - element to insert
Returns:
position the object was inserted at

search

public java.lang.Object search(java.lang.Object o)
Performs a binary search on the sorted array list.
Parameters:
o - Object to search for using the set comparator
Returns:
the found object from the array list or null instead

compare

protected int compare(java.lang.Object o1,
                      java.lang.Object o2)
Compares two elements. This is done using the given comparator. If no comparator is set, both objects are casted to Comparable. A o1.compareTo( o2 ) is invoked afterwards.
Parameters:
o1 - first object
o2 - second object
Returns:
result of comparison

add

public void add(java.lang.Object[] array)
Inserts an array into the array list.
Parameters:
array - array to insert into the vector

removeRangeRange

public void removeRangeRange(int fromIndex,
                             int toIndex)
Deletes a range in the array list. The range is between fromIndex (inclusive) to toIndex (exclusive). This is a wrapper for ArrayList.removeRange(), that is set to protected (who knows why ...).
Parameters:
fromIndex - lower index
toIndex - upper index

setComparator

public void setComparator(java.util.Comparator c)
Sets a new comparator.
Parameters:
c - new comparator

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS