|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.siebengeisslein.client.Persistent
org.siebengeisslein.collections.AbstractCollection<EntryType>
org.siebengeisslein.collections.AbstractPersistentList<EntryType>
org.siebengeisslein.collections.TreeList<EntryType>
public class TreeList<EntryType>
A List implementation that is optimised for fast insertions and
removals at any index in the list.
This list implementation utilises a tree structure internally to ensure that
all insertions and removals are O(log n). This provides much faster performance
than both an 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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.siebengeisslein.collections.AbstractPersistentList |
|---|
AbstractPersistentList.ArrayIterator, AbstractPersistentList.ArrayListIterator, AbstractPersistentList.SubList<T> |
| Constructor Summary | |
|---|---|
TreeList()
Constructs a new empty list. |
|
TreeList(java.util.Collection coll)
Constructs a new empty list that copies the specified list. |
|
| Method Summary | |
|---|---|
void |
add(int index,
EntryType obj)
Adds a new element to the list. |
void |
clear()
Clears the list, removing all entries. |
boolean |
contains(java.lang.Object object)
Searches for the presence of an object in the list. |
EntryType |
get(int index)
Gets the element at the specified index. |
org.siebengeisslein.collections.TreeList.AVLNode |
getRoot()
|
int |
indexOf(java.lang.Object object)
Searches for the index of an object in the list. |
java.util.Iterator |
iterator()
Gets an iterator over the list. |
java.util.ListIterator |
listIterator()
Gets a ListIterator over the list. |
java.util.ListIterator |
listIterator(int fromIndex)
Gets a ListIterator over the list. |
EntryType |
remove(int index)
Removes the element at the specified index. |
EntryType |
set(int index,
EntryType obj)
Sets the element at the specified index. |
int |
size()
Gets the current size of the list. |
EntryType[] |
toArray()
Converts the list into an array. |
| Methods inherited from class org.siebengeisslein.collections.AbstractPersistentList |
|---|
add, addAll, checkVersion, equals, hashCode, lastIndexOf, remove, subList |
| Methods inherited from class org.siebengeisslein.collections.AbstractCollection |
|---|
addAll, containsAll, getVersion, incVersion, isEmpty, removeAll, retainAll, toArray, toString |
| Methods inherited from class org.siebengeisslein.client.Persistent |
|---|
abort, clearUserLocals, clone, commit, disposeTransient, getGroup, getRef, getTransientValue, initTransient, isWriteTransaction, joinWriteTransaction, readLock, setGroup, setTransientValue, toPersistent, toRef, writeExternal, writeLock |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
addAll, containsAll, isEmpty, removeAll, retainAll, toArray |
| Constructor Detail |
|---|
public TreeList()
public TreeList(java.util.Collection coll)
coll - the collection to copy
java.lang.NullPointerException - if the collection is null| Method Detail |
|---|
public EntryType get(int index)
index - the index to retrieve
public int size()
public java.util.Iterator iterator()
iterator in interface java.lang.Iterable<EntryType>iterator in interface java.util.Collection<EntryType>iterator in interface java.util.List<EntryType>iterator in class AbstractPersistentList<EntryType>public java.util.ListIterator listIterator()
listIterator in interface java.util.List<EntryType>listIterator in class AbstractPersistentList<EntryType>public java.util.ListIterator listIterator(int fromIndex)
listIterator in interface java.util.List<EntryType>listIterator in class AbstractPersistentList<EntryType>fromIndex - the index to start from
public int indexOf(java.lang.Object object)
indexOf in interface java.util.List<EntryType>indexOf in class AbstractPersistentList<EntryType>public boolean contains(java.lang.Object object)
contains in interface java.util.Collection<EntryType>contains in interface java.util.List<EntryType>contains in class AbstractPersistentList<EntryType>public EntryType[] toArray()
toArray in interface java.util.Collection<EntryType>toArray in interface java.util.List<EntryType>toArray in class AbstractCollection<EntryType>
public void add(int index,
EntryType obj)
index - the index to add beforeobj - the element to add
public EntryType set(int index,
EntryType obj)
index - the index to setobj - the object to store at the specified index
java.lang.IndexOutOfBoundsException - if the index is invalidpublic EntryType remove(int index)
index - the index to remove
public void clear()
clear in interface java.util.Collection<EntryType>clear in interface java.util.List<EntryType>clear in class AbstractPersistentList<EntryType>public org.siebengeisslein.collections.TreeList.AVLNode getRoot()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||