|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
jodd.util.collection.SortedArrayList<E>
public class SortedArrayList<E>
An extension of ArrayList that insures that all of the items
added are sorted. This breaks original list contract!.
A binary search method is used to provide a quick way to
auto sort this list.Note: Not all methods for adding and
removing elements are supported.
| Field Summary | |
|---|---|
protected java.util.Comparator<E> |
comparator
|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
SortedArrayList()
Constructs a new SortedArrayList expecting
elements are comparable. |
|
SortedArrayList(java.util.Collection<? extends E> c)
Constructs a new SortedArrayList expecting
elements are comparable. |
|
SortedArrayList(java.util.Comparator<E> c)
Constructs a new SortedArrayList. |
|
| Method Summary | |
|---|---|
boolean |
add(E o)
Adds an Object to sorted list. |
void |
add(int index,
E element)
|
boolean |
addAll(java.util.Collection<? extends E> c)
Add all of the elements in the given collection to this list. |
boolean |
addAll(int index,
java.util.Collection<? extends E> c)
|
protected int |
compare(E k1,
E k2)
Compares two keys using the correct comparison method for this collection. |
int |
findInsertionPoint(E o)
Finds the index at which object should be inserted. |
protected int |
findInsertionPoint(E o,
int low,
int high)
Conducts a binary search to find the index where Object should be inserted. |
java.util.Comparator |
getComparator()
Returns comparator assigned to this collection, if such exist. |
E |
set(int index,
E element)
|
| Methods inherited from class java.util.ArrayList |
|---|
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, 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, 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 |
| Field Detail |
|---|
protected final java.util.Comparator<E> comparator
| Constructor Detail |
|---|
public SortedArrayList(java.util.Comparator<E> c)
SortedArrayList.
public SortedArrayList()
SortedArrayList expecting
elements are comparable.
public SortedArrayList(java.util.Collection<? extends E> c)
SortedArrayList expecting
elements are comparable.
| Method Detail |
|---|
public java.util.Comparator getComparator()
public boolean add(E o)
This method breaks original list contract since objects are not added at the list end, but in sorted manner.
add in interface java.util.Collection<E>add in interface java.util.List<E>add in class java.util.ArrayList<E>public boolean addAll(java.util.Collection<? extends E> c)
addAll in interface java.util.Collection<E>addAll in interface java.util.List<E>addAll in class java.util.ArrayList<E>public int findInsertionPoint(E o)
public void add(int index,
E element)
add in interface java.util.List<E>add in class java.util.ArrayList<E>java.lang.UnsupportedOperationException - This method not supported.
public E set(int index,
E element)
set in interface java.util.List<E>set in class java.util.ArrayList<E>java.lang.UnsupportedOperationException - This method not supported.
public boolean addAll(int index,
java.util.Collection<? extends E> c)
addAll in interface java.util.List<E>addAll in class java.util.ArrayList<E>java.lang.UnsupportedOperationException - This method not supported.
protected int compare(E k1,
E k2)
protected int findInsertionPoint(E o,
int low,
int high)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||