|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<E>
public class LinkedList<E>
LinkedList is an implementation of List, backed by a linked list. All optional operations are supported, adding, removing and replacing. The elements can be any objects.
| Field Summary | |
|---|---|
(package private) int |
size
|
(package private) java.util.LinkedList.Link<E> |
voidLink
|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
LinkedList()
Constructs a new empty instance of LinkedList. |
|
LinkedList(Collection<? extends E> collection)
Constructs a new instance of LinkedList that holds
all of the elements contained in the supplied collection
argument. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E object)
Adds the specified object at the end of this LinkedList. |
|
void |
add(int location,
E object)
Inserts the specified object into this LinkedList at the specified location. |
|
boolean |
addAll(Collection<? extends E> collection)
Adds the objects in the specified Collection to this LinkedList. |
|
boolean |
addAll(int location,
Collection<? extends E> collection)
Inserts the objects in the specified Collection at the specified location in this LinkedList. |
|
void |
addFirst(E object)
Adds the specified object at the beginning of this LinkedList. |
|
void |
addLast(E object)
Adds the specified object at the end of this LinkedList. |
|
void |
clear()
Removes all elements from this LinkedList, leaving it empty. |
|
Object |
clone()
Returns a new LinkedList with the same elements and size as this LinkedList. |
|
boolean |
contains(Object object)
Searches this LinkedList for the specified object. |
|
E |
element()
Gets but not removes the element in the head of the queue. |
|
E |
get(int location)
Returns the element at the specified location in this List. |
|
E |
getFirst()
Returns the first element in this LinkedList. |
|
E |
getLast()
Returns the last element in this LinkedList. |
|
int |
indexOf(Object object)
Searches this LinkedList for the specified object and returns the index of the first occurrence. |
|
int |
lastIndexOf(Object object)
Searches this LinkedList for the specified object and returns the index of the last occurrence. |
|
ListIterator<E> |
listIterator(int location)
Returns a ListIterator on the elements of this LinkedList. |
|
boolean |
offer(E o)
Inserts the specified element into the queue provided that the condition allows such an operation. |
|
E |
peek()
Gets but not removes the element in the head of the queue, or throws exception if there is no element in the queue. |
|
E |
poll()
Gets and removes the element in the head of the queue, or returns null if there is no element in the queue. |
|
E |
remove()
Gets and removes the element in the head of the queue. |
|
E |
remove(int location)
Removes the object at the specified location from this LinkedList. |
|
boolean |
remove(Object object)
Removes the first occurrence of the specified object from this Collection. |
|
E |
removeFirst()
Removes the first object from this LinkedList. |
|
E |
removeLast()
Removes the last object from this LinkedList. |
|
E |
set(int location,
E object)
Replaces the element at the specified location in this LinkedList with the specified object. |
|
int |
size()
Returns the number of elements in this LinkedList. |
|
Object[] |
toArray()
Returns a new array containing all elements contained in this LinkedList. |
|
|
toArray(T[] contents)
Returns an array containing all elements contained in this LinkedList. |
|
| Methods inherited from class java.util.AbstractSequentialList |
|---|
iterator |
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, listIterator, removeRange, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, isEmpty, removeAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList |
| Field Detail |
|---|
transient int size
transient java.util.LinkedList.Link<E> voidLink
| Constructor Detail |
|---|
public LinkedList()
public LinkedList(Collection<? extends E> collection)
LinkedList that holds
all of the elements contained in the supplied collection
argument. The order of the elements in this new LinkedList
will be determined by the iteration order of collection.
collection - the collection of elements to add| Method Detail |
|---|
public void add(int location,
E object)
add in interface List<E>add in class AbstractSequentialList<E>location - the index at which to insertobject - the object to add
IndexOutOfBoundsException - when location < 0 || >= size()public boolean add(E object)
add in interface Collection<E>add in interface List<E>add in class AbstractList<E>object - the object to add
public boolean addAll(int location,
Collection<? extends E> collection)
Collection iterator.
addAll in interface List<E>addAll in class AbstractSequentialList<E>location - the index at which to insertcollection - the Collection of objects
IndexOutOfBoundsException - when
location < 0 || > size()public boolean addAll(Collection<? extends E> collection)
addAll in interface Collection<E>addAll in interface List<E>addAll in class AbstractCollection<E>collection - the Collection of objects
public void addFirst(E object)
object - the object to addpublic void addLast(E object)
object - the object to addpublic void clear()
clear in interface Collection<E>clear in interface List<E>clear in class AbstractList<E>List.isEmpty(),
sizepublic Object clone()
clone in class ObjectCloneablepublic boolean contains(Object object)
contains in interface Collection<E>contains in interface List<E>contains in class AbstractCollection<E>object - the object to search for
object is an element of this LinkedList,
false otherwisepublic E get(int location)
AbstractSequentialList
get in interface List<E>get in class AbstractSequentialList<E>location - the index of the element to return
public E getFirst()
NoSuchElementException - when this LinkedList is emptypublic E getLast()
NoSuchElementException - when this LinkedList is emptypublic int indexOf(Object object)
indexOf in interface List<E>indexOf in class AbstractList<E>object - the object to search for
public int lastIndexOf(Object object)
lastIndexOf in interface List<E>lastIndexOf in class AbstractList<E>object - the object to search for
public ListIterator<E> listIterator(int location)
listIterator in interface List<E>listIterator in class AbstractSequentialList<E>location - the index at which to start the iteration
IndexOutOfBoundsException - when location < 0 || >= size()ListIteratorpublic E remove(int location)
remove in interface List<E>remove in class AbstractSequentialList<E>location - the index of the object to remove
IndexOutOfBoundsException - when location < 0 || >= size()public boolean remove(Object object)
AbstractCollection
remove in interface Collection<E>remove in interface List<E>remove in class AbstractCollection<E>object - the object to remove
public E removeFirst()
NoSuchElementException - when this LinkedList is emptypublic E removeLast()
NoSuchElementException - when this LinkedList is empty
public E set(int location,
E object)
set in interface List<E>set in class AbstractSequentialList<E>location - the index at which to put the specified objectobject - the object to add
IndexOutOfBoundsException - when location < 0 || >= size()public int size()
size in interface Collection<E>size in interface List<E>size in class AbstractCollection<E>public boolean offer(E o)
Queue
offer in interface Queue<E>o - the specified element to insert into the queue.
public E poll()
Queue
poll in interface Queue<E>public E remove()
Queue
remove in interface Queue<E>public E peek()
Queue
peek in interface Queue<E>public E element()
Queue
element in interface Queue<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] contents)
toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>contents - the array
ArrayStoreException - when the type of an element in this LinkedList cannot be
stored in the type of the specified array
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||