|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections15.list.AbstractLinkedList<E>
public abstract class AbstractLinkedList<E>
An abstract implementation of a linked list which provides numerous points for subclasses to override.
Overridable methods are provided to change the storage node and to change how nodes are added to and removed. Hopefully, all you need for unusual subclasses is here.
| Nested Class Summary | |
|---|---|
protected static class |
AbstractLinkedList.LinkedListIterator<E>
A list iterator over the linked list. |
protected static class |
AbstractLinkedList.LinkedSubList<E>
The sublist implementation for AbstractLinkedList. |
protected static class |
AbstractLinkedList.LinkedSubListIterator<E>
A list iterator over the linked sub list. |
protected static class |
AbstractLinkedList.Node<T>
A node within the linked list. |
| Field Summary | |
|---|---|
protected AbstractLinkedList.Node<E> |
header
A AbstractLinkedList.Node which indicates the start and end of the list and does not
hold a value. |
protected int |
modCount
Modification count for iterators |
protected int |
size
The size of the list |
| Constructor Summary | |
|---|---|
protected |
AbstractLinkedList()
Constructor that does nothing intended for deserialization. |
protected |
AbstractLinkedList(Collection<E> coll)
Constructs a list copying data from the specified collection. |
| Method Summary | ||
|---|---|---|
boolean |
add(E value)
|
|
void |
add(int index,
E value)
|
|
boolean |
addAll(Collection<? extends E> coll)
|
|
boolean |
addAll(int index,
Collection<? extends E> coll)
|
|
boolean |
addFirst(E o)
|
|
boolean |
addLast(E o)
|
|
protected void |
addNode(AbstractLinkedList.Node<E> nodeToInsert,
AbstractLinkedList.Node<E> insertBeforeNode)
Inserts a new node into the list. |
|
protected void |
addNodeAfter(AbstractLinkedList.Node<E> node,
E value)
Creates a new node with the specified object as its value and inserts it after node. |
|
protected void |
addNodeBefore(AbstractLinkedList.Node<E> node,
E value)
Creates a new node with the specified object as its value and inserts it before node. |
|
void |
clear()
|
|
boolean |
contains(Object value)
|
|
boolean |
containsAll(Collection<?> coll)
|
|
protected AbstractLinkedList.Node<E> |
createHeaderNode()
Creates a new node with previous, next and element all set to null. |
|
protected AbstractLinkedList.Node<E> |
createNode(E value)
Creates a new node with the specified properties. |
|
protected Iterator<E> |
createSubListIterator(AbstractLinkedList.LinkedSubList<E> subList)
Creates an iterator for the sublist. |
|
protected ListIterator<E> |
createSubListListIterator(AbstractLinkedList.LinkedSubList<E> subList,
int fromIndex)
Creates a list iterator for the sublist. |
|
protected void |
doReadObject(ObjectInputStream inputStream)
Deserializes the data held in this object to the stream specified. |
|
protected void |
doWriteObject(ObjectOutputStream outputStream)
Serializes the data held in this object to the stream specified. |
|
boolean |
equals(Object obj)
|
|
E |
get(int index)
|
|
E |
getFirst()
|
|
E |
getLast()
|
|
protected AbstractLinkedList.Node<E> |
getNode(int index,
boolean endMarkerAllowed)
Gets the node at a particular index. |
|
int |
hashCode()
|
|
int |
indexOf(Object value)
|
|
protected void |
init()
The equivalent of a default constructor, broken out so it can be called by any constructor and by readObject. |
|
boolean |
isEmpty()
|
|
protected boolean |
isEqualValue(E value1,
E value2)
Compares two values for equals. |
|
Iterator<E> |
iterator()
|
|
int |
lastIndexOf(Object value)
|
|
ListIterator<E> |
listIterator()
|
|
ListIterator<E> |
listIterator(int fromIndex)
|
|
E |
remove(int index)
|
|
boolean |
remove(Object value)
|
|
boolean |
removeAll(Collection<?> coll)
|
|
protected void |
removeAllNodes()
Removes all nodes by resetting the circular list marker. |
|
E |
removeFirst()
|
|
E |
removeLast()
|
|
protected void |
removeNode(AbstractLinkedList.Node<E> node)
Removes the specified node from the list. |
|
boolean |
retainAll(Collection<?> coll)
|
|
E |
set(int index,
E value)
|
|
int |
size()
|
|
List<E> |
subList(int fromIndexInclusive,
int toIndexExclusive)
Gets a sublist of the main list. |
|
Object[] |
toArray()
|
|
|
toArray(T[] array)
|
|
String |
toString()
|
|
protected void |
updateNode(AbstractLinkedList.Node<E> node,
E value)
Updates the node with a new value. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected transient AbstractLinkedList.Node<E> header
AbstractLinkedList.Node which indicates the start and end of the list and does not
hold a value. The value of next is the first item in the
list. The value of of previous is the last item in the list.
protected transient int size
protected transient int modCount
| Constructor Detail |
|---|
protected AbstractLinkedList()
protected AbstractLinkedList(Collection<E> coll)
coll - the collection to copy| Method Detail |
|---|
protected void init()
readObject.
Subclasses which override this method should make sure they call super,
so the list is initialised properly.
public int size()
size in interface Collection<E>size in interface List<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface List<E>public E get(int index)
get in interface List<E>public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface List<E>public ListIterator<E> listIterator()
listIterator in interface List<E>public ListIterator<E> listIterator(int fromIndex)
listIterator in interface List<E>public int indexOf(Object value)
indexOf in interface List<E>public int lastIndexOf(Object value)
lastIndexOf in interface List<E>public boolean contains(Object value)
contains in interface Collection<E>contains in interface List<E>public boolean containsAll(Collection<?> coll)
containsAll in interface Collection<E>containsAll in interface List<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface List<E>public <T> T[] toArray(T[] array)
toArray in interface Collection<E>toArray in interface List<E>
public List<E> subList(int fromIndexInclusive,
int toIndexExclusive)
subList in interface List<E>fromIndexInclusive - the index to start fromtoIndexExclusive - the index to end at
public boolean add(E value)
add in interface Collection<E>add in interface List<E>
public void add(int index,
E value)
add in interface List<E>public boolean addAll(Collection<? extends E> coll)
addAll in interface Collection<E>addAll in interface List<E>
public boolean addAll(int index,
Collection<? extends E> coll)
addAll in interface List<E>public E remove(int index)
remove in interface List<E>public boolean remove(Object value)
remove in interface Collection<E>remove in interface List<E>public boolean removeAll(Collection<?> coll)
removeAll in interface Collection<E>removeAll in interface List<E>public boolean retainAll(Collection<?> coll)
retainAll in interface Collection<E>retainAll in interface List<E>
public E set(int index,
E value)
set in interface List<E>public void clear()
clear in interface Collection<E>clear in interface List<E>public E getFirst()
public E getLast()
public boolean addFirst(E o)
public boolean addLast(E o)
public E removeFirst()
public E removeLast()
public boolean equals(Object obj)
equals in interface Collection<E>equals in interface List<E>equals in class Objectpublic int hashCode()
hashCode in interface Collection<E>hashCode in interface List<E>hashCode in class Objectpublic String toString()
toString in class Object
protected boolean isEqualValue(E value1,
E value2)
value1 - the first value to compare, may be nullvalue2 - the second value to compare, may be null
protected void updateNode(AbstractLinkedList.Node<E> node,
E value)
node - node to updatevalue - new value of the nodeprotected AbstractLinkedList.Node<E> createHeaderNode()
protected AbstractLinkedList.Node<E> createNode(E value)
value - value of the new node
protected void addNodeBefore(AbstractLinkedList.Node<E> node,
E value)
value and inserts it before node.
This implementation uses createNode(Object) and
addNode(AbstractLinkedList.Node,AbstractLinkedList.Node).
node - node to insert beforevalue - value of the newly added node
NullPointerException - if node is null
protected void addNodeAfter(AbstractLinkedList.Node<E> node,
E value)
value and inserts it after node.
This implementation uses createNode(Object) and
addNode(AbstractLinkedList.Node,AbstractLinkedList.Node).
node - node to insert aftervalue - value of the newly added node
NullPointerException - if node is null
protected void addNode(AbstractLinkedList.Node<E> nodeToInsert,
AbstractLinkedList.Node<E> insertBeforeNode)
nodeToInsert - new node to insertinsertBeforeNode - node to insert before
NullPointerException - if either node is nullprotected void removeNode(AbstractLinkedList.Node<E> node)
node - the node to remove
NullPointerException - if node is nullprotected void removeAllNodes()
protected AbstractLinkedList.Node<E> getNode(int index,
boolean endMarkerAllowed)
throws IndexOutOfBoundsException
index - the index, starting from 0endMarkerAllowed - whether or not the end marker can be returned if
startIndex is set to the list's size
IndexOutOfBoundsException - if the index is less than 0; equal to
the size of the list and endMakerAllowed is false; or greater than the
size of the listprotected Iterator<E> createSubListIterator(AbstractLinkedList.LinkedSubList<E> subList)
subList - the sublist to get an iterator for
protected ListIterator<E> createSubListListIterator(AbstractLinkedList.LinkedSubList<E> subList,
int fromIndex)
subList - the sublist to get an iterator forfromIndex - the index to start from, relative to the sublist
protected void doWriteObject(ObjectOutputStream outputStream)
throws IOException
writeObject.
IOException
protected void doReadObject(ObjectInputStream inputStream)
throws IOException,
ClassNotFoundException
readObject.
IOException
ClassNotFoundException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||