Class AbstractLinkedList<E>
- Type Parameters:
E
- the type of elements in this list
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
- Direct Known Subclasses:
CursorableLinkedList
,NodeCachingLinkedList
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.
- Since:
- 3.0
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Deprecated.A list iterator over the linked list.protected static class
Deprecated.The sublist implementation for AbstractLinkedList.protected static class
Deprecated.A list iterator over the linked sub list.protected static class
Deprecated.A node within the linked list. -
Constructor Summary
ModifierConstructorDescriptionprotected
Deprecated.Constructor that does nothing (intended for deserialization).protected
AbstractLinkedList
(Collection<? extends E> coll) Deprecated.Constructs a list copying data from the specified collection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.boolean
Deprecated.boolean
addAll
(int index, Collection<? extends E> coll) Deprecated.boolean
addAll
(Collection<? extends E> coll) Deprecated.boolean
Deprecated.Adds an element at the beginning.boolean
Deprecated.Adds an element at the end.protected void
addNode
(AbstractLinkedList.Node<E> nodeToInsert, AbstractLinkedList.Node<E> insertBeforeNode) Deprecated.Inserts a new node into the list.protected void
addNodeAfter
(AbstractLinkedList.Node<E> node, E value) Deprecated.Creates a new node with the specified object as itsvalue
and inserts it afternode
.protected void
addNodeBefore
(AbstractLinkedList.Node<E> node, E value) Deprecated.Creates a new node with the specified object as itsvalue
and inserts it beforenode
.void
clear()
Deprecated.boolean
Deprecated.boolean
containsAll
(Collection<?> coll) Deprecated.protected AbstractLinkedList.Node
<E> Deprecated.Creates a new node with previous, next and element all set to null.protected AbstractLinkedList.Node
<E> createNode
(E value) Deprecated.Creates a new node with the specified properties.Deprecated.Creates an iterator for the sublist.protected ListIterator
<E> createSubListListIterator
(AbstractLinkedList.LinkedSubList<E> subList, int fromIndex) Deprecated.Creates a list iterator for the sublist.protected void
doReadObject
(ObjectInputStream inputStream) Deprecated.Deserializes the data held in this object to the stream specified.protected void
doWriteObject
(ObjectOutputStream outputStream) Deprecated.Serializes the data held in this object to the stream specified.boolean
Deprecated.get
(int index) Deprecated.getFirst()
Deprecated.Gets the first element.getLast()
Deprecated.Gets the last element.protected AbstractLinkedList.Node
<E> getNode
(int index, boolean endMarkerAllowed) Deprecated.Gets the node at a particular index.int
hashCode()
Deprecated.int
Deprecated.protected void
init()
Deprecated.The equivalent of a default constructor, broken out so it can be called by any constructor and byreadObject
.boolean
isEmpty()
Deprecated.protected boolean
isEqualValue
(Object value1, Object value2) Deprecated.Compares two values for equals.iterator()
Deprecated.int
lastIndexOf
(Object value) Deprecated.Deprecated.listIterator
(int fromIndex) Deprecated.remove
(int index) Deprecated.boolean
Deprecated.boolean
removeAll
(Collection<?> coll) Deprecated.protected void
Deprecated.Removes all nodes by resetting the circular list marker.Deprecated.Removes the first element.Deprecated.Removes the last element.protected void
removeNode
(AbstractLinkedList.Node<E> node) Deprecated.Removes the specified node from the list.boolean
retainAll
(Collection<?> coll) Deprecated.Deprecated.int
size()
Deprecated.subList
(int fromIndexInclusive, int toIndexExclusive) Deprecated.Gets a sublist of the main list.Object[]
toArray()
Deprecated.<T> T[]
toArray
(T[] array) Deprecated.toString()
Deprecated.protected void
updateNode
(AbstractLinkedList.Node<E> node, E value) Deprecated.Updates the node with a new value.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Constructor Details
-
AbstractLinkedList
protected AbstractLinkedList()Deprecated.Constructor that does nothing (intended for deserialization).If this constructor is used by a serializable subclass then the init() method must be called.
-
AbstractLinkedList
Deprecated.Constructs a list copying data from the specified collection.- Parameters:
coll
- the collection to copy
-
-
Method Details
-
add
Deprecated. -
add
Deprecated. -
addAll
Deprecated. -
addAll
Deprecated. -
addFirst
Deprecated.Adds an element at the beginning.- Parameters:
e
- the element to beginning.- Returns:
- true.
-
addLast
Deprecated.Adds an element at the end.- Parameters:
e
- the element to add.- Returns:
- true.
-
addNode
protected void addNode(AbstractLinkedList.Node<E> nodeToInsert, AbstractLinkedList.Node<E> insertBeforeNode) Deprecated.Inserts a new node into the list.- Parameters:
nodeToInsert
- new node to insertinsertBeforeNode
- node to insert before- Throws:
NullPointerException
- if either node is null
-
addNodeAfter
Deprecated.Creates a new node with the specified object as itsvalue
and inserts it afternode
.This implementation uses
createNode(Object)
andaddNode(AbstractLinkedList.Node,AbstractLinkedList.Node)
.- Parameters:
node
- node to insert aftervalue
- value of the newly added node- Throws:
NullPointerException
- ifnode
is null
-
addNodeBefore
Deprecated.Creates a new node with the specified object as itsvalue
and inserts it beforenode
.This implementation uses
createNode(Object)
andaddNode(AbstractLinkedList.Node,AbstractLinkedList.Node)
.- Parameters:
node
- node to insert beforevalue
- value of the newly added node- Throws:
NullPointerException
- ifnode
is null
-
clear
Deprecated. -
contains
Deprecated. -
containsAll
Deprecated.- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
-
createHeaderNode
Deprecated.Creates a new node with previous, next and element all set to null. This implementation creates a new empty Node. Subclasses can override this to create a different class.- Returns:
- newly created node
-
createNode
Deprecated.Creates a new node with the specified properties. This implementation creates a new Node with data. Subclasses can override this to create a different class.- Parameters:
value
- value of the new node- Returns:
- a new node containing the value
-
createSubListIterator
Deprecated.Creates an iterator for the sublist.- Parameters:
subList
- the sublist to get an iterator for- Returns:
- a new iterator on the given sublist
-
createSubListListIterator
protected ListIterator<E> createSubListListIterator(AbstractLinkedList.LinkedSubList<E> subList, int fromIndex) Deprecated.Creates a list iterator for the sublist.- Parameters:
subList
- the sublist to get an iterator forfromIndex
- the index to start from, relative to the sublist- Returns:
- a new list iterator on the given sublist
-
doReadObject
protected void doReadObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException Deprecated.Deserializes the data held in this object to the stream specified.The first serializable subclass must call this method from
readObject
.- Parameters:
inputStream
- the stream to read the object from- Throws:
IOException
- if any error occurs while reading from the streamClassNotFoundException
- if a class read from the stream cannot be loaded
-
doWriteObject
Deprecated.Serializes the data held in this object to the stream specified.The first serializable subclass must call this method from
writeObject
.- Parameters:
outputStream
- the stream to write the object to- Throws:
IOException
- if anything goes wrong
-
equals
Deprecated. -
get
Deprecated. -
getFirst
Deprecated.Gets the first element.- Returns:
- the first element.
-
getLast
Deprecated.Gets the last element.- Returns:
- the last element.
-
getNode
protected AbstractLinkedList.Node<E> getNode(int index, boolean endMarkerAllowed) throws IndexOutOfBoundsException Deprecated.Gets the node at a particular index.- Parameters:
index
- the index, starting from 0endMarkerAllowed
- whether or not the end marker can be returned if startIndex is set to the list's size- Returns:
- the node at the given index
- Throws:
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 list
-
hashCode
Deprecated. -
indexOf
Deprecated. -
init
Deprecated.The equivalent of a default constructor, broken out so it can be called by any constructor and byreadObject
. Subclasses which override this method should make sure they call super, so the list is initialized properly. -
isEmpty
Deprecated. -
isEqualValue
Deprecated.Compares two values for equals. This implementation uses the equals method. Subclasses can override this to match differently.- Parameters:
value1
- the first value to compare, may be nullvalue2
- the second value to compare, may be null- Returns:
- true if equal
-
iterator
Deprecated. -
lastIndexOf
Deprecated.- Specified by:
lastIndexOf
in interfaceList<E>
-
listIterator
Deprecated.- Specified by:
listIterator
in interfaceList<E>
-
listIterator
Deprecated.- Specified by:
listIterator
in interfaceList<E>
-
remove
Deprecated. -
remove
Deprecated. -
removeAll
Deprecated.This implementation iterates over the elements of this list, checking each element in turn to see if it's contained in
coll
. If it's contained, it's removed from this list. As a consequence, it is advised to use a collection type forcoll
that provides a fast (e.g. O(1)) implementation ofCollection.contains(Object)
. -
removeAllNodes
Deprecated.Removes all nodes by resetting the circular list marker. -
removeFirst
Deprecated.Removes the first element.- Returns:
- The value removed.
-
removeLast
Deprecated.Removes the last element.- Returns:
- The value removed.
-
removeNode
Deprecated.Removes the specified node from the list.- Parameters:
node
- the node to remove- Throws:
NullPointerException
- ifnode
is null
-
retainAll
Deprecated.This implementation iterates over the elements of this list, checking each element in turn to see if it's contained in
coll
. If it's not contained, it's removed from this list. As a consequence, it is advised to use a collection type forcoll
that provides a fast (e.g. O(1)) implementation ofCollection.contains(Object)
. -
set
Deprecated. -
size
Deprecated. -
subList
Deprecated.Gets a sublist of the main list. -
toArray
Deprecated. -
toArray
Deprecated. -
toString
Deprecated. -
updateNode
Deprecated.Updates the node with a new value. This implementation sets the value on the node. Subclasses can override this to record the change.- Parameters:
node
- node to updatevalue
- new value of the node
-
AbstractLinkedListJava21
instead