Class AbstractLinkedList<E>
- java.lang.Object
-
- org.apache.commons.collections4.list.AbstractLinkedList<E>
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
- Direct Known Subclasses:
CursorableLinkedList
,NodeCachingLinkedList
public abstract class AbstractLinkedList<E> extends Object implements List<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.
- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, E value)
boolean
add(E value)
boolean
addAll(int index, Collection<? extends E> coll)
boolean
addAll(Collection<? extends E> coll)
boolean
addFirst(E o)
boolean
addLast(E o)
void
clear()
boolean
contains(Object value)
boolean
containsAll(Collection<?> coll)
boolean
equals(Object obj)
E
get(int index)
E
getFirst()
E
getLast()
int
hashCode()
int
indexOf(Object value)
boolean
isEmpty()
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)
E
removeFirst()
E
removeLast()
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()
<T> T[]
toArray(T[] array)
String
toString()
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
-
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIterator
in interfaceList<E>
-
listIterator
public ListIterator<E> listIterator(int fromIndex)
- Specified by:
listIterator
in interfaceList<E>
-
lastIndexOf
public int lastIndexOf(Object value)
- Specified by:
lastIndexOf
in interfaceList<E>
-
contains
public boolean contains(Object value)
-
containsAll
public boolean containsAll(Collection<?> coll)
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] array)
-
subList
public List<E> subList(int fromIndexInclusive, int toIndexExclusive)
Gets a sublist of the main list.
-
add
public boolean add(E value)
-
addAll
public boolean addAll(Collection<? extends E> coll)
-
addAll
public boolean addAll(int index, Collection<? extends E> coll)
-
remove
public boolean remove(Object value)
-
removeAll
public boolean removeAll(Collection<?> coll)
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)
.
-
retainAll
public boolean retainAll(Collection<?> coll)
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)
.
-
clear
public void clear()
-
getFirst
public E getFirst()
-
getLast
public E getLast()
-
addFirst
public boolean addFirst(E o)
-
addLast
public boolean addLast(E o)
-
removeFirst
public E removeFirst()
-
removeLast
public E removeLast()
-
equals
public boolean equals(Object obj)
-
hashCode
public int hashCode()
-
-