|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections.list.AbstractLinkedList
public abstract class AbstractLinkedList
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
A list iterator over the linked list. |
protected static class |
AbstractLinkedList.LinkedSubList
The sublist implementation for AbstractLinkedList. |
protected static class |
AbstractLinkedList.LinkedSubListIterator
A list iterator over the linked sub list. |
protected static class |
AbstractLinkedList.Node
A node within the linked list. |
| Field Summary | |
|---|---|
protected AbstractLinkedList.Node |
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(java.util.Collection coll)
Constructs a list copying data from the specified collection. |
| Method Summary | |
|---|---|
void |
add(int index,
java.lang.Object value)
|
boolean |
add(java.lang.Object value)
|
boolean |
addAll(java.util.Collection coll)
|
boolean |
addAll(int index,
java.util.Collection coll)
|
boolean |
addFirst(java.lang.Object o)
|
boolean |
addLast(java.lang.Object o)
|
protected void |
addNode(AbstractLinkedList.Node nodeToInsert,
AbstractLinkedList.Node insertBeforeNode)
Inserts a new node into the list. |
protected void |
addNodeAfter(AbstractLinkedList.Node node,
java.lang.Object value)
Creates a new node with the specified object as its value and inserts it after node. |
protected void |
addNodeBefore(AbstractLinkedList.Node node,
java.lang.Object value)
Creates a new node with the specified object as its value and inserts it before node. |
void |
clear()
|
boolean |
contains(java.lang.Object value)
|
boolean |
containsAll(java.util.Collection coll)
|
protected AbstractLinkedList.Node |
createHeaderNode()
Creates a new node with previous, next and element all set to null. |
protected AbstractLinkedList.Node |
createNode(java.lang.Object value)
Creates a new node with the specified properties. |
protected java.util.Iterator |
createSubListIterator(AbstractLinkedList.LinkedSubList subList)
Creates an iterator for the sublist. |
protected java.util.ListIterator |
createSubListListIterator(AbstractLinkedList.LinkedSubList subList,
int fromIndex)
Creates a list iterator for the sublist. |
protected void |
doReadObject(java.io.ObjectInputStream inputStream)
Deserializes the data held in this object to the stream specified. |
protected void |
doWriteObject(java.io.ObjectOutputStream outputStream)
Serializes the data held in this object to the stream specified. |
boolean |
equals(java.lang.Object obj)
|
java.lang.Object |
get(int index)
|
java.lang.Object |
getFirst()
|
java.lang.Object |
getLast()
|
protected AbstractLinkedList.Node |
getNode(int index,
boolean endMarkerAllowed)
Gets the node at a particular index. |
int |
hashCode()
|
int |
indexOf(java.lang.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(java.lang.Object value1,
java.lang.Object value2)
Compares two values for equals. |
java.util.Iterator |
iterator()
|
int |
lastIndexOf(java.lang.Object value)
|
java.util.ListIterator |
listIterator()
|
java.util.ListIterator |
listIterator(int fromIndex)
|
java.lang.Object |
remove(int index)
|
boolean |
remove(java.lang.Object value)
|
boolean |
removeAll(java.util.Collection coll)
|
protected void |
removeAllNodes()
Removes all nodes by resetting the circular list marker. |
java.lang.Object |
removeFirst()
|
java.lang.Object |
removeLast()
|
protected void |
removeNode(AbstractLinkedList.Node node)
Removes the specified node from the list. |
boolean |
retainAll(java.util.Collection coll)
|
java.lang.Object |
set(int index,
java.lang.Object value)
|
int |
size()
|
java.util.List |
subList(int fromIndexInclusive,
int toIndexExclusive)
Gets a sublist of the main list. |
java.lang.Object[] |
toArray()
|
java.lang.Object[] |
toArray(java.lang.Object[] array)
|
java.lang.String |
toString()
|
protected void |
updateNode(AbstractLinkedList.Node node,
java.lang.Object 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 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()
If this constructor is used by a serializable subclass then the init() method must be called.
protected AbstractLinkedList(java.util.Collection 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 java.util.Collectionsize in interface java.util.Listpublic boolean isEmpty()
isEmpty in interface java.util.CollectionisEmpty in interface java.util.Listpublic java.lang.Object get(int index)
get in interface java.util.Listpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterableiterator in interface java.util.Collectioniterator in interface java.util.Listpublic java.util.ListIterator listIterator()
listIterator in interface java.util.Listpublic java.util.ListIterator listIterator(int fromIndex)
listIterator in interface java.util.Listpublic int indexOf(java.lang.Object value)
indexOf in interface java.util.Listpublic int lastIndexOf(java.lang.Object value)
lastIndexOf in interface java.util.Listpublic boolean contains(java.lang.Object value)
contains in interface java.util.Collectioncontains in interface java.util.Listpublic boolean containsAll(java.util.Collection coll)
containsAll in interface java.util.CollectioncontainsAll in interface java.util.Listpublic java.lang.Object[] toArray()
toArray in interface java.util.CollectiontoArray in interface java.util.Listpublic java.lang.Object[] toArray(java.lang.Object[] array)
toArray in interface java.util.CollectiontoArray in interface java.util.List
public java.util.List subList(int fromIndexInclusive,
int toIndexExclusive)
subList in interface java.util.ListfromIndexInclusive - the index to start fromtoIndexExclusive - the index to end at
public boolean add(java.lang.Object value)
add in interface java.util.Collectionadd in interface java.util.List
public void add(int index,
java.lang.Object value)
add in interface java.util.Listpublic boolean addAll(java.util.Collection coll)
addAll in interface java.util.CollectionaddAll in interface java.util.List
public boolean addAll(int index,
java.util.Collection coll)
addAll in interface java.util.Listpublic java.lang.Object remove(int index)
remove in interface java.util.Listpublic boolean remove(java.lang.Object value)
remove in interface java.util.Collectionremove in interface java.util.Listpublic boolean removeAll(java.util.Collection coll)
removeAll in interface java.util.CollectionremoveAll in interface java.util.Listpublic boolean retainAll(java.util.Collection coll)
retainAll in interface java.util.CollectionretainAll in interface java.util.List
public java.lang.Object set(int index,
java.lang.Object value)
set in interface java.util.Listpublic void clear()
clear in interface java.util.Collectionclear in interface java.util.Listpublic java.lang.Object getFirst()
public java.lang.Object getLast()
public boolean addFirst(java.lang.Object o)
public boolean addLast(java.lang.Object o)
public java.lang.Object removeFirst()
public java.lang.Object removeLast()
public boolean equals(java.lang.Object obj)
equals in interface java.util.Collectionequals in interface java.util.Listequals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.CollectionhashCode in interface java.util.ListhashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
protected boolean isEqualValue(java.lang.Object value1,
java.lang.Object value2)
value1 - the first value to compare, may be nullvalue2 - the second value to compare, may be null
protected void updateNode(AbstractLinkedList.Node node,
java.lang.Object value)
node - node to updatevalue - new value of the nodeprotected AbstractLinkedList.Node createHeaderNode()
protected AbstractLinkedList.Node createNode(java.lang.Object value)
value - value of the new node
protected void addNodeBefore(AbstractLinkedList.Node node,
java.lang.Object 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
java.lang.NullPointerException - if node is null
protected void addNodeAfter(AbstractLinkedList.Node node,
java.lang.Object 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
java.lang.NullPointerException - if node is null
protected void addNode(AbstractLinkedList.Node nodeToInsert,
AbstractLinkedList.Node insertBeforeNode)
nodeToInsert - new node to insertinsertBeforeNode - node to insert before
java.lang.NullPointerException - if either node is nullprotected void removeNode(AbstractLinkedList.Node node)
node - the node to remove
java.lang.NullPointerException - if node is nullprotected void removeAllNodes()
protected AbstractLinkedList.Node getNode(int index,
boolean endMarkerAllowed)
throws java.lang.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
java.lang.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 java.util.Iterator createSubListIterator(AbstractLinkedList.LinkedSubList subList)
subList - the sublist to get an iterator for
protected java.util.ListIterator createSubListListIterator(AbstractLinkedList.LinkedSubList subList,
int fromIndex)
subList - the sublist to get an iterator forfromIndex - the index to start from, relative to the sublist
protected void doWriteObject(java.io.ObjectOutputStream outputStream)
throws java.io.IOException
The first serializable subclass must call this method from
writeObject.
java.io.IOException
protected void doReadObject(java.io.ObjectInputStream inputStream)
throws java.io.IOException,
java.lang.ClassNotFoundException
The first serializable subclass must call this method from
readObject.
java.io.IOException
java.lang.ClassNotFoundException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||