org.openbp.common.util
Class SortingArrayList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList
              extended by org.openbp.common.util.SortingArrayList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess

public class SortingArrayList
extends java.util.ArrayList

Array list that sorts its contents. If the setAutoSort(boolean) property is set to true, the list will sort after any add operation to the list. Otherwise, the sort() method must be called. The list will use the comparator You may set the sorter using setComparator(java.util.Comparator) method.

Author:
Heiko Erhardt
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SortingArrayList()
          Default constructor.
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
protected  void autoSort()
          Invokes the automatic sorting if enabled.
 java.util.Comparator getComparator()
          Gets the element comparator.
 boolean isAutoSort()
          Gets the auto sort property.
 void setAutoSort(boolean autoSort)
          Sets the auto sort property.
 void setComparator(java.util.Comparator comparator)
          Sets the element comparator.
 void sort()
          Sorts the list.
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, 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, 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, removeAll, retainAll, subList
 

Constructor Detail

SortingArrayList

public SortingArrayList()
Default constructor.

Method Detail

getComparator

public java.util.Comparator getComparator()
Gets the element comparator.


setComparator

public void setComparator(java.util.Comparator comparator)
Sets the element comparator.


isAutoSort

public boolean isAutoSort()
Gets the auto sort property.


setAutoSort

public void setAutoSort(boolean autoSort)
Sets the auto sort property.


sort

public void sort()
Sorts the list.


autoSort

protected void autoSort()
Invokes the automatic sorting if enabled.


add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.ArrayList

add

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

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.ArrayList

addAll

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


Copyright © 2011. All Rights Reserved.