LinkedList (Java SE 26 & JDK 26)
- Type Parameters:
E- the type of elements held in this collection
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>, SequencedCollection<E>
-
Field Summary
Fields declared in class AbstractList
protected intThe number of times this list has been structurally modified.
-
Constructor Summary
Constructors
Constructs an empty list.
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
-
Method Summary
voidInserts the specified element at the specified position in this list.
booleanAppends the specified element to the end of this list.
booleanInserts all of the elements in the specified collection into this list, starting at the specified position.
booleanAppends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.
voidInserts the specified element at the beginning of this list.
voidAppends the specified element to the end of this list.
voidclear()Removes all of the elements from this list.
clone()Returns a shallow copy of this
LinkedList.booleanReturns
trueif this list contains the specified element.Returns an iterator over the elements in this deque in reverse sequential order.
element()Retrieves, but does not remove, the head (first element) of this list.
get(int index) Returns the element at the specified position in this list.
getFirst()Returns the first element in this list.
getLast()Returns the last element in this list.
intReturns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
intReturns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
listIterator(int index) Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list.
booleanAdds the specified element as the tail (last element) of this list.
booleanofferFirst(E e) Inserts the specified element at the front of this list.
booleanInserts the specified element at the end of this list.
peek()Retrieves, but does not remove, the head (first element) of this list.
Retrieves, but does not remove, the first element of this list, or returns
nullif this list is empty.peekLast()Retrieves, but does not remove, the last element of this list, or returns
nullif this list is empty.poll()Retrieves and removes the head (first element) of this list.
Retrieves and removes the first element of this list, or returns
nullif this list is empty.pollLast()Retrieves and removes the last element of this list, or returns
nullif this list is empty.pop()Pops an element from the stack represented by this list.
voidPushes an element onto the stack represented by this list.
remove()Retrieves and removes the head (first element) of this list.
remove(int index) Removes the element at the specified position in this list.
booleanRemoves the first occurrence of the specified element from this list, if it is present.
Removes and returns the first element from this list.
booleanRemoves the first occurrence of the specified element in this list (when traversing the list from head to tail).
Removes and returns the last element from this list.
booleanRemoves the last occurrence of the specified element in this list (when traversing the list from head to tail).
reversed()Returns a reverse-ordered view of this collection.
Replaces the element at the specified position in this list with the specified element.
intsize()Returns the number of elements in this list.
toArray()Returns an array containing all of the elements in this list in proper sequence (from first to last element).
<T> T[]toArray(T[] a) Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.
Methods declared in class AbstractList
equals, hashCode, listIterator, removeRange, subListbooleanCompares the specified object with this list for equality.
intReturns the hash code value for this list.
Returns a list iterator over the elements in this list (in proper sequence).
protected voidRemoves from this list all of the elements whose index is between
fromIndex, inclusive, andtoIndex, exclusive.subList(int fromIndex, int toIndex) Returns a view of the portion of this list between the specified
fromIndex, inclusive, andtoIndex, exclusive.Methods declared in class AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toStringbooleanReturns
trueif this collection contains all of the elements in the specified collection.booleanReturns
trueif this collection contains no elements.booleanRemoves all of this collection's elements that are also contained in the specified collection (optional operation).
booleanRetains only the elements in this collection that are contained in the specified collection (optional operation).
Returns a string representation of this collection.
Methods declared in class Object
finalize, getClass, notify, notifyAll, wait, wait, waitprotected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
Methods declared in interface Collection
parallelStream, removeIf, stream, toArrayReturns a possibly parallel
Streamwith this collection as its source.default booleanRemoves all of the elements of this collection that satisfy the given predicate (optional operation).
Returns a sequential
Streamwith this collection as its source.default <T> T[]Returns an array containing all of the elements in this collection, using the provided
generatorfunction to allocate the returned array.Methods declared in interface Deque
Returns an iterator over the elements in this deque in proper sequence.
Methods declared in interface Iterable
default voidPerforms the given action for each element of the
Iterableuntil all elements have been processed or the action throws an exception.Methods declared in interface List
containsAll, isEmpty, removeAll, replaceAll, retainAll, sortbooleanReturns
trueif this list contains all of the elements of the specified collection.booleanReturns
trueif this list contains no elements.booleanRemoves from this list all of its elements that are contained in the specified collection (optional operation).
default voidReplaces each element of this list with the result of applying the operator to that element (optional operation).
booleanRetains only the elements in this list that are contained in the specified collection (optional operation).
default voidSorts this list according to the order induced by the specified
Comparator(optional operation).
-
Constructor Details
-
LinkedList
-
LinkedList
-
-
Method Details
-
getFirst
-
getLast
-
removeFirst
-
removeLast
-
addFirst
-
addLast
-
contains
-
size
-
add
-
remove
-
addAll
-
addAll
-
clear
-
get
-
set
-
add
-
remove
-
indexOf
-
lastIndexOf
-
peek
-
element
-
poll
-
remove
-
offer
-
offerFirst
-
offerLast
-
peekFirst
-
peekLast
-
pollFirst
-
pollLast
-
push
-
pop
-
removeFirstOccurrence
-
removeLastOccurrence
-
listIterator
-
descendingIterator
-
clone
-
toArray
-
toArray
-
spliterator
-
reversed
-