|
GNU Trove | |||||||||
| 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.AbstractSequentialList<T>
gnu.trove.TLinkedList<T>
public class TLinkedList<T extends TLinkable>
A LinkedList implementation which holds instances of type TLinkable.
Using this implementation allows you to get java.util.LinkedList behavior (a doubly linked list, with Iterators that support insert and delete operations) without incurring the overhead of creating Node wrapper objects for every element in your list.
The requirement to achieve this time/space gain is that the Objects stored in the List implement the TLinkable interface.
The limitations are that you cannot put the same object into more than one list or more than once in the same list. You must also ensure that you only remove objects that are actually in the list. That is, if you have an object A and lists l1 and l2, you must ensure that you invoke List.remove(A) on the correct list. It is also forbidden to invoke List.remove() with an unaffiliated TLinkable (one that belongs to no list): this will destroy the list you invoke it on.
Created: Sat Nov 10 15:25:10 2001
TLinkable,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
TLinkedList.IteratorImpl
A ListIterator that supports additions and deletions. |
| Field Summary | |
|---|---|
protected T |
_head
the head of the list |
protected int |
_size
the number of elements in the list |
protected T |
_tail
the tail of the list |
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
TLinkedList()
Creates a new TLinkedList instance. |
|
| Method Summary | |
|---|---|
void |
add(int index,
T linkable)
Inserts linkable at index index in the list. |
boolean |
add(T linkable)
Appends linkable to the end of the list. |
void |
addAfter(T current,
T newElement)
Inserts newElement into the list immediately after current. |
void |
addBefore(T current,
T newElement)
Inserts newElement into the list immediately before current. |
void |
addFirst(T linkable)
Inserts linkable at the head of the list. |
void |
addLast(T linkable)
Adds linkable to the end of the list. |
void |
clear()
Empties the list. |
boolean |
contains(java.lang.Object o)
A linear search for o in the list. |
boolean |
forEachValue(TObjectProcedure<T> procedure)
Executes procedure for each entry in the list. |
T |
get(int index)
|
T |
getFirst()
Returns the head of the list |
T |
getLast()
Returns the tail of the list. |
T |
getNext(T current)
Return the node following the given node. |
T |
getPrevious(T current)
Return the node preceding the given node. |
protected void |
insert(int index,
T linkable)
Implementation of index-based list insertions. |
java.util.ListIterator<T> |
listIterator(int index)
Returns an iterator positioned at index. |
void |
readExternal(java.io.ObjectInput in)
|
boolean |
remove(java.lang.Object o)
Removes the specified element from the list. |
T |
removeFirst()
Remove and return the first element in the list. |
T |
removeLast()
Remove and return the last element in the list. |
int |
size()
Returns the number of elements in the list. |
java.lang.Object[] |
toArray()
Copies the list's contents into a native array. |
java.lang.Object[] |
toUnlinkedArray()
Copies the list to a native array, destroying the next/previous links as the copy is made. |
void |
writeExternal(java.io.ObjectOutput out)
|
| Methods inherited from class java.util.AbstractSequentialList |
|---|
addAll, iterator, remove, set |
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, containsAll, isEmpty, 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, removeAll, retainAll, toArray |
| Field Detail |
|---|
protected T extends TLinkable _head
protected T extends TLinkable _tail
protected int _size
| Constructor Detail |
|---|
public TLinkedList()
TLinkedList instance.
| Method Detail |
|---|
public java.util.ListIterator<T> listIterator(int index)
listIterator in interface java.util.List<T extends TLinkable>listIterator in class java.util.AbstractSequentialList<T extends TLinkable>index - an int value
ListIterator valuepublic int size()
size in interface java.util.Collection<T extends TLinkable>size in interface java.util.List<T extends TLinkable>size in class java.util.AbstractCollection<T extends TLinkable>int value
public void add(int index,
T linkable)
add in interface java.util.List<T extends TLinkable>add in class java.util.AbstractSequentialList<T extends TLinkable>index - an int valuelinkable - an object of type TLinkablepublic boolean add(T linkable)
add in interface java.util.Collection<T extends TLinkable>add in interface java.util.List<T extends TLinkable>add in class java.util.AbstractList<T extends TLinkable>linkable - an object of type TLinkable
public void addFirst(T linkable)
linkable - an object of type TLinkablepublic void addLast(T linkable)
linkable - an object of type TLinkablepublic void clear()
clear in interface java.util.Collection<T extends TLinkable>clear in interface java.util.List<T extends TLinkable>clear in class java.util.AbstractList<T extends TLinkable>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<T extends TLinkable>toArray in interface java.util.List<T extends TLinkable>toArray in class java.util.AbstractCollection<T extends TLinkable>Object[] valuepublic java.lang.Object[] toUnlinkedArray()
Object[] valuepublic boolean contains(java.lang.Object o)
contains in interface java.util.Collection<T extends TLinkable>contains in interface java.util.List<T extends TLinkable>contains in class java.util.AbstractCollection<T extends TLinkable>o - an Object value
boolean valuepublic T get(int index)
get in interface java.util.List<T extends TLinkable>get in class java.util.AbstractSequentialList<T extends TLinkable>public T getFirst()
Object valuepublic T getLast()
Object valuepublic T getNext(T current)
NOTE: this should only be used with nodes contained in the list. The results are undefined with anything else.
public T getPrevious(T current)
NOTE: this should only be used with nodes contained in the list. The results are undefined with anything else.
public T removeFirst()
Object valuepublic T removeLast()
Object value
protected void insert(int index,
T linkable)
index - an int valuelinkable - an object of type TLinkablepublic boolean remove(java.lang.Object o)
remove in interface java.util.Collection<T extends TLinkable>remove in interface java.util.List<T extends TLinkable>remove in class java.util.AbstractCollection<T extends TLinkable>o - a TLinkable element already inserted in this list.
public void addBefore(T current,
T newElement)
current - a TLinkable value currently in the list.newElement - a TLinkable value to be added to
the list.
public void addAfter(T current,
T newElement)
current - a TLinkable value currently in the list.newElement - a TLinkable value to be added to
the list.public boolean forEachValue(TObjectProcedure<T> procedure)
procedure - a TObjectProcedure value
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOException
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOException
java.lang.ClassNotFoundException
|
GNU Trove | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||