public class LinkedList extends java.util.AbstractSequentialList implements java.util.List, Deque, java.lang.Cloneable, java.io.Serializable
| Constructor and Description |
|---|
LinkedList() |
LinkedList(java.util.Collection c) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
java.lang.Object element) |
boolean |
add(java.lang.Object o)
Inserts the specified element into the queue represented by this deque
(in other words, at the tail of this deque) if it is possible to do so
immediately without violating capacity restrictions, returning
true upon success and throwing an
IllegalStateException if no space is currently available.
|
boolean |
addAll(java.util.Collection c) |
boolean |
addAll(int index,
java.util.Collection c) |
void |
addFirst(java.lang.Object e)
Inserts the specified element at the front of this deque if it is
possible to do so immediately without violating capacity restrictions.
|
void |
addLast(java.lang.Object e)
Inserts the specified element at the end of this deque if it is
possible to do so immediately without violating capacity restrictions.
|
void |
clear() |
java.lang.Object |
clone() |
boolean |
contains(java.lang.Object o)
Returns true if this deque contains the specified element.
|
java.util.Iterator |
descendingIterator()
Returns an iterator over the elements in this deque in reverse
sequential order.
|
java.lang.Object |
element()
Retrieves, but does not remove, the head of the queue represented by
this deque (in other words, the first element of this deque).
|
java.lang.Object |
get(int index) |
java.lang.Object |
getFirst()
Retrieves, but does not remove, the first element of this deque.
|
java.lang.Object |
getLast()
Retrieves, but does not remove, the last element of this deque.
|
int |
indexOf(java.lang.Object o) |
boolean |
isEmpty() |
int |
lastIndexOf(java.lang.Object o) |
java.util.ListIterator |
listIterator() |
java.util.ListIterator |
listIterator(int index) |
boolean |
offer(java.lang.Object e)
Inserts the specified element into the queue represented by this deque
(in other words, at the tail of this deque) if it is possible to do so
immediately without violating capacity restrictions, returning
true upon success and false if no space is currently
available.
|
boolean |
offerFirst(java.lang.Object e)
Inserts the specified element at the front of this deque unless it would
violate capacity restrictions.
|
boolean |
offerLast(java.lang.Object e)
Inserts the specified element at the end of this deque unless it would
violate capacity restrictions.
|
java.lang.Object |
peek()
Retrieves, but does not remove, the head of the queue represented by
this deque (in other words, the first element of this deque), or
returns null if this deque is empty.
|
java.lang.Object |
peekFirst()
Retrieves, but does not remove, the first element of this deque,
or returns null if this deque is empty.
|
java.lang.Object |
peekLast()
Retrieves, but does not remove, the last element of this deque,
or returns null if this deque is empty.
|
java.lang.Object |
poll()
Retrieves and removes the head of the queue represented by this deque
(in other words, the first element of this deque), or returns
null if this deque is empty.
|
java.lang.Object |
pollFirst()
Retrieves and removes the first element of this deque,
or returns null if this deque is empty.
|
java.lang.Object |
pollLast()
Retrieves and removes the last element of this deque,
or returns null if this deque is empty.
|
java.lang.Object |
pop()
Pops an element from the stack represented by this deque.
|
void |
push(java.lang.Object e)
Pushes an element onto the stack represented by this deque (in other
words, at the head of this deque) if it is possible to do so
immediately without violating capacity restrictions, returning
true upon success and throwing an
IllegalStateException if no space is currently available.
|
java.lang.Object |
remove()
Retrieves and removes the head of the queue represented by this deque
(in other words, the first element of this deque).
|
java.lang.Object |
remove(int index) |
boolean |
remove(java.lang.Object o)
Removes the first occurrence of the specified element from this deque.
|
java.lang.Object |
removeFirst()
Retrieves and removes the first element of this deque.
|
boolean |
removeFirstOccurrence(java.lang.Object o)
Removes the first occurrence of the specified element from this deque.
|
java.lang.Object |
removeLast()
Retrieves and removes the last element of this deque.
|
boolean |
removeLastOccurrence(java.lang.Object o)
Removes the last occurrence of the specified element from this deque.
|
java.lang.Object |
set(int index,
java.lang.Object element) |
int |
size()
Returns the number of elements in this deque.
|
java.lang.Object[] |
toArray() |
java.lang.Object[] |
toArray(java.lang.Object[] a) |
containsAll, removeAll, retainAll, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitpublic LinkedList()
public LinkedList(java.util.Collection c)
public int size()
Dequepublic boolean isEmpty()
isEmpty in interface java.util.CollectionisEmpty in interface java.util.ListisEmpty in class java.util.AbstractCollectionpublic boolean contains(java.lang.Object o)
Dequecontains in interface Dequecontains in interface java.util.Collectioncontains in interface java.util.Listcontains in class java.util.AbstractCollectiono - element whose presence in this deque is to be testedpublic int indexOf(java.lang.Object o)
indexOf in interface java.util.ListindexOf in class java.util.AbstractListpublic int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.ListlastIndexOf in class java.util.AbstractListpublic java.lang.Object[] toArray()
toArray in interface java.util.CollectiontoArray in interface java.util.ListtoArray in class java.util.AbstractCollectionpublic java.lang.Object[] toArray(java.lang.Object[] a)
toArray in interface java.util.CollectiontoArray in interface java.util.ListtoArray in class java.util.AbstractCollectionpublic boolean add(java.lang.Object o)
Dequeoffer.
This method is equivalent to Deque.addLast(java.lang.Object).
add in interface Dequeadd in interface Queueadd in interface java.util.Collectionadd in interface java.util.Listadd in class java.util.AbstractListo - the element to addCollection.add(java.lang.Object))public boolean remove(java.lang.Object o)
DequeThis method is equivalent to Deque.removeFirstOccurrence(java.lang.Object).
remove in interface Dequeremove in interface java.util.Collectionremove in interface java.util.Listremove in class java.util.AbstractCollectiono - element to be removed from this deque, if presentpublic boolean addAll(java.util.Collection c)
addAll in interface java.util.CollectionaddAll in interface java.util.ListaddAll in class java.util.AbstractCollectionpublic boolean addAll(int index,
java.util.Collection c)
addAll in interface java.util.ListaddAll in class java.util.AbstractSequentialListpublic void clear()
clear in interface java.util.Collectionclear in interface java.util.Listclear in class java.util.AbstractListpublic java.lang.Object get(int index)
get in interface java.util.Listget in class java.util.AbstractSequentialListpublic java.lang.Object set(int index,
java.lang.Object element)
set in interface java.util.Listset in class java.util.AbstractSequentialListpublic void add(int index,
java.lang.Object element)
add in interface java.util.Listadd in class java.util.AbstractSequentialListpublic java.lang.Object remove(int index)
remove in interface java.util.Listremove in class java.util.AbstractSequentialListpublic java.util.ListIterator listIterator()
listIterator in interface java.util.ListlistIterator in class java.util.AbstractListpublic java.util.ListIterator listIterator(int index)
listIterator in interface java.util.ListlistIterator in class java.util.AbstractSequentialListpublic void addFirst(java.lang.Object e)
DequeDeque.offerFirst(java.lang.Object).public void addLast(java.lang.Object e)
DequeDeque.offerLast(java.lang.Object).
This method is equivalent to Deque.add(java.lang.Object).
public boolean offerFirst(java.lang.Object e)
DequeDeque.addFirst(java.lang.Object) method,
which can fail to insert an element only by throwing an exception.offerFirst in interface Dequee - the element to addpublic boolean offerLast(java.lang.Object e)
DequeDeque.addLast(java.lang.Object) method,
which can fail to insert an element only by throwing an exception.public java.lang.Object removeFirst()
DequepollFirst only in that it throws an
exception if this deque is empty.removeFirst in interface Dequepublic java.lang.Object removeLast()
DequepollLast only in that it throws an
exception if this deque is empty.removeLast in interface Dequepublic java.lang.Object pollFirst()
Dequepublic java.lang.Object pollLast()
Dequepublic java.lang.Object getFirst()
DequepeekFirst only in that it
throws an exception if this deque is empty.public java.lang.Object getLast()
DequepeekLast only in that it
throws an exception if this deque is empty.public java.lang.Object peekFirst()
Dequepublic java.lang.Object peekLast()
Dequepublic boolean removeFirstOccurrence(java.lang.Object o)
DequeremoveFirstOccurrence in interface Dequeo - element to be removed from this deque, if presentpublic boolean removeLastOccurrence(java.lang.Object o)
DequeremoveLastOccurrence in interface Dequeo - element to be removed from this deque, if presentpublic boolean offer(java.lang.Object e)
DequeDeque.add(java.lang.Object) method, which can fail to
insert an element only by throwing an exception.
This method is equivalent to Deque.offerLast(java.lang.Object).
public java.lang.Object remove()
Dequepoll only in that it throws an
exception if this deque is empty.
This method is equivalent to Deque.removeFirst().
public java.lang.Object poll()
DequeThis method is equivalent to Deque.pollFirst().
public java.lang.Object element()
Dequepeek only in that it throws an
exception if this deque is empty.
This method is equivalent to Deque.getFirst().
public java.lang.Object peek()
DequeThis method is equivalent to Deque.peekFirst().
public void push(java.lang.Object e)
DequeThis method is equivalent to Deque.addFirst(java.lang.Object).
public java.lang.Object pop()
DequeThis method is equivalent to Deque.removeFirst().
public java.util.Iterator descendingIterator()
DequedescendingIterator in interface Dequepublic java.lang.Object clone()
clone in class java.lang.Object