Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
AbstractSequentialList
edu.emory.mathcs.backport.java.util.LinkedList
public class LinkedList
extends AbstractSequentialList
implements List, Deque, Cloneable, Serializable
Constructor Summary | |
|
Method Summary | |
boolean |
|
void |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
Object |
|
boolean |
|
Iterator |
|
Object |
|
Object |
|
Object |
|
Object |
|
int |
|
boolean |
|
int |
|
ListIterator | |
ListIterator |
|
boolean |
|
boolean |
|
boolean |
|
Object |
|
Object |
|
Object |
|
Object |
|
Object |
|
Object |
|
Object |
|
void |
|
Object |
|
boolean |
|
Object |
|
Object |
|
boolean |
|
Object |
|
boolean |
|
Object |
|
int |
|
Object[] |
|
Object[] |
|
public boolean add(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. When using a capacity-restricted deque, it is generally preferable to useoffer
. This method is equivalent toDeque.addLast(Object)
.
- Parameters:
- Returns:
- true (as specified by
java.util.Collection.add
)
public void add(int index, Object element)
public boolean addAll(Collection c)
public boolean addAll(int index, Collection c)
public void addFirst(Object e)
Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted deque, it is generally preferable to use methodDeque.offerFirst(Object)
.
- Parameters:
e
- the element to add
public void addLast(Object e)
Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted deque, it is generally preferable to use methodDeque.offerLast(Object)
. This method is equivalent toDeque.add(Object)
.
- Parameters:
e
- the element to add
public void clear()
public Object clone()
public boolean contains(Object o)
Returns true if this deque contains the specified element. More formally, returns true if and only if this deque contains at least one element e such that (o==null ? e==null : o.equals(e)).
- Parameters:
o
- element whose presence in this deque is to be tested
- Returns:
- true if this deque contains the specified element
public Iterator descendingIterator()
Returns an iterator over the elements in this deque in reverse sequential order. The elements will be returned in order from last (tail) to first (head).
- Specified by:
- descendingIterator in interface Deque
- Returns:
- an iterator over the elements in this deque in reverse sequence
public 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). This method differs frompeek
only in that it throws an exception if this deque is empty. This method is equivalent toDeque.getFirst()
.
- Returns:
- the head of the queue represented by this deque
public Object get(int index)
public Object getFirst()
Retrieves, but does not remove, the first element of this deque. This method differs frompeekFirst
only in that it throws an exception if this deque is empty.
- Returns:
- the head of this deque
public Object getLast()
Retrieves, but does not remove, the last element of this deque. This method differs frompeekLast
only in that it throws an exception if this deque is empty.
- Returns:
- the tail of this deque
public int indexOf(Object o)
public boolean isEmpty()
public int lastIndexOf(Object o)
public ListIterator listIterator()
public ListIterator listIterator(int index)
public boolean offer(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. When using a capacity-restricted deque, this method is generally preferable to theDeque.add(Object)
method, which can fail to insert an element only by throwing an exception. This method is equivalent toDeque.offerLast(Object)
.
- Parameters:
e
- the element to add
- Returns:
- true if the element was added to this deque, else false
public boolean offerFirst(Object e)
Inserts the specified element at the front of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to theDeque.addFirst(Object)
method, which can fail to insert an element only by throwing an exception.
- Specified by:
- offerFirst in interface Deque
- Parameters:
e
- the element to add
- Returns:
- true if the element was added to this deque, else false
public boolean offerLast(Object e)
Inserts the specified element at the end of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to theDeque.addLast(Object)
method, which can fail to insert an element only by throwing an exception.
- Parameters:
e
- the element to add
- Returns:
- true if the element was added to this deque, else false
public 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. This method is equivalent toDeque.peekFirst()
.
- Returns:
- the head of the queue represented by this deque, or null if this deque is empty
public Object peekFirst()
Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.
- Returns:
- the head of this deque, or null if this deque is empty
public Object peekLast()
Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.
- Returns:
- the tail of this deque, or null if this deque is empty
public 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. This method is equivalent toDeque.pollFirst()
.
- Returns:
- the first element of this deque, or null if this deque is empty
public Object pollFirst()
Retrieves and removes the first element of this deque, or returns null if this deque is empty.
- Returns:
- the head of this deque, or null if this deque is empty
public Object pollLast()
Retrieves and removes the last element of this deque, or returns null if this deque is empty.
- Returns:
- the tail of this deque, or null if this deque is empty
public Object pop()
Pops an element from the stack represented by this deque. In other words, removes and returns the first element of this deque. This method is equivalent toDeque.removeFirst()
.
- Returns:
- the element at the front of this deque (which is the top of the stack represented by this deque)
public void push(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. This method is equivalent toDeque.addFirst(Object)
.
- Parameters:
e
- the element to push
public Object remove()
Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque). This method differs frompoll
only in that it throws an exception if this deque is empty. This method is equivalent toDeque.removeFirst()
.
- Returns:
- the head of the queue represented by this deque
public boolean remove(Object o)
Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that (o==null ? e==null : o.equals(e)) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call). This method is equivalent toDeque.removeFirstOccurrence(Object)
.
- Parameters:
o
- element to be removed from this deque, if present
- Returns:
- true if an element was removed as a result of this call
public Object remove(int index)
public Object removeFirst()
Retrieves and removes the first element of this deque. This method differs frompollFirst
only in that it throws an exception if this deque is empty.
- Specified by:
- removeFirst in interface Deque
- Returns:
- the head of this deque
public boolean removeFirstOccurrence(Object o)
Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that (o==null ? e==null : o.equals(e)) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).
- Specified by:
- removeFirstOccurrence in interface Deque
- Parameters:
o
- element to be removed from this deque, if present
- Returns:
- true if an element was removed as a result of this call
public Object removeLast()
Retrieves and removes the last element of this deque. This method differs frompollLast
only in that it throws an exception if this deque is empty.
- Specified by:
- removeLast in interface Deque
- Returns:
- the tail of this deque
public boolean removeLastOccurrence(Object o)
Removes the last occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the last element e such that (o==null ? e==null : o.equals(e)) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).
- Specified by:
- removeLastOccurrence in interface Deque
- Parameters:
o
- element to be removed from this deque, if present
- Returns:
- true if an element was removed as a result of this call
public Object set(int index, Object element)
public int size()
Returns the number of elements in this deque.
- Returns:
- the number of elements in this deque
public Object[] toArray()
public Object[] toArray(Object[] a)