|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> java.util.ArrayList<E> ccs.utils.SortedArrayList<E>
public class SortedArrayList<E>
An array-backed list which maintains its elements in order: either their natural order (if they all implement Comparable) or the order provided by a specified Comparator. This structure is useful for lists which are not expected to become very large; for large structures you should probably look at a more sophisticated structure (eg. a TreeSet) instead. MT-UNSAFE.
Field Summary | |
---|---|
static int |
INITCAP
The default initial capacity. |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
SortedArrayList()
An empty list using natural ordering and a default initial capacity. |
|
SortedArrayList(java.util.Comparator<? super E> c)
An empty list using a comparator and default initial capacity. |
|
SortedArrayList(int initcap,
java.util.Comparator<? super E> c)
An empty list using a comparator and an initial capacity. |
Method Summary | |
---|---|
boolean |
add(E o)
Add the object, in its correct location (NB. not necessarily at the end). |
void |
add(int idx,
E o)
In order to ensure ordering, this method is not supported. |
int |
firstIndexOf(java.lang.Object o)
Return the index of the first (guaranteed) object equal to that supplied. |
E |
get(java.lang.Object o)
Return an object from the list which is equal to the specified object, if present; otherwise null. |
int |
indexOf(java.lang.Object o)
Return the index of the object, if present, or -1 if not. |
int |
lastIndexOf(java.lang.Object o)
Return the index of the last (guaranteed) object equal to that supplied. |
void |
removeRange(int fromIdx,
int toIdx)
Remove a range of members. |
protected int |
seek(java.lang.Object o)
Find the index of the specified object, if present; if not, returns -(x+1) where x is the index where the object should be inserted. |
E |
set(int idx,
E o)
Replace the existing element at the specified index with a new one. |
Methods inherited from class java.util.ArrayList |
---|
addAll, addAll, clear, clone, contains, ensureCapacity, get, isEmpty, remove, remove, 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 |
---|
public static final int INITCAP
Constructor Detail |
---|
public SortedArrayList()
public SortedArrayList(java.util.Comparator<? super E> c)
public SortedArrayList(int initcap, java.util.Comparator<? super E> c)
initcap
- The initial capacity.c
- The comparator. Supply null for natural ordering.Method Detail |
---|
public boolean add(E o)
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
add
in class java.util.ArrayList<E>
public void add(int idx, E o)
add
in interface java.util.List<E>
add
in class java.util.ArrayList<E>
public E get(java.lang.Object o)
public E set(int idx, E o)
set
in interface java.util.List<E>
set
in class java.util.ArrayList<E>
java.lang.IllegalArgumentException
- if the new object would not be in order
with respect to its neighbours.public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<E>
indexOf
in class java.util.ArrayList<E>
public int firstIndexOf(java.lang.Object o)
public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<E>
lastIndexOf
in class java.util.ArrayList<E>
public void removeRange(int fromIdx, int toIdx)
removeRange
in class java.util.ArrayList<E>
fromIdx
- The first index to remove (ie. inclusive).toIdx
- The first subsequent index to *leave* (ie. exclusive). If
fromIdx >= toIdx the method does nothing.protected int seek(java.lang.Object o)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |