|
||||||||||
| 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>
org.apache.commons.collections15.list.TreeList<E>
public class TreeList<E>
A List implementation that is optimised for fast insertions and
removals at any index in the list.
ArrayList and a LinkedList where elements
are inserted and removed repeatedly from anywhere in the list.
The following relative performance statistics are indicative of this class:
get add insert iterate remove
TreeList 3 5 1 2 1
ArrayList 1 1 40 1 40
LinkedList 5800 1 350 2 325
ArrayList is a good general purpose list implementation.
It is faster than TreeList for most operations except inserting
and removing in the middle of the list. ArrayList also uses less
memory as TreeList uses one object per entry.
LinkedList is rarely a good choice of implementation.
TreeList is almost always a good replacement for it, although it
does use sligtly more memory.
| Field Summary |
|---|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
TreeList()
Constructs a new empty list. |
|
TreeList(Collection<? extends E> coll)
Constructs a new empty list that copies the specified list. |
|
| Method Summary | |
|---|---|
void |
add(int index,
E obj)
Adds a new element to the list. |
void |
clear()
Clears the list, removing all entries. |
boolean |
contains(Object object)
Searches for the presence of an object in the list. |
E |
get(int index)
Gets the element at the specified index. |
int |
indexOf(Object object)
Searches for the index of an object in the list. |
Iterator<E> |
iterator()
Gets an iterator over the list. |
ListIterator<E> |
listIterator()
Gets a ListIterator over the list. |
ListIterator<E> |
listIterator(int fromIndex)
Gets a ListIterator over the list. |
E |
remove(int index)
Removes the element at the specified index. |
E |
set(int index,
E obj)
Sets the element at the specified index. |
int |
size()
Gets the current size of the list. |
Object[] |
toArray()
Converts the list into an array. |
| Methods inherited from class java.util.AbstractList |
|---|
add, addAll, equals, hashCode, lastIndexOf, removeRange, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray |
| Constructor Detail |
|---|
public TreeList()
public TreeList(Collection<? extends E> coll)
coll - the collection to copy
NullPointerException - if the collection is null| Method Detail |
|---|
public E get(int index)
get in interface List<E>get in class AbstractList<E>index - the index to retrieve
public int size()
size in interface Collection<E>size in interface List<E>size in class AbstractCollection<E>public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface List<E>iterator in class AbstractList<E>public ListIterator<E> listIterator()
listIterator in interface List<E>listIterator in class AbstractList<E>public ListIterator<E> listIterator(int fromIndex)
listIterator in interface List<E>listIterator in class AbstractList<E>fromIndex - the index to start from
public int indexOf(Object object)
indexOf in interface List<E>indexOf in class AbstractList<E>public boolean contains(Object object)
contains in interface Collection<E>contains in interface List<E>contains in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>
public void add(int index,
E obj)
add in interface List<E>add in class AbstractList<E>index - the index to add beforeobj - the element to add
public E set(int index,
E obj)
set in interface List<E>set in class AbstractList<E>index - the index to setobj - the object to store at the specified index
IndexOutOfBoundsException - if the index is invalidpublic E remove(int index)
remove in interface List<E>remove in class AbstractList<E>index - the index to remove
public void clear()
clear in interface Collection<E>clear in interface List<E>clear in class AbstractList<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||