|
APCS Java Subset | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectap.java.util.LinkedList
The LinkedList class is only used
in the AB course.
This is a linked list implementation of
the List interface. In addition to
the standard List methods, this class supplies
methods to get, insert, and remove elements
at the beginning and end of the list.
The underlying implementation uses a doubly-linked list so that all add/set/remove operations at the beginning and end of the list are constant-time or O(1) operations.
| Constructor Summary | |
LinkedList()
|
|
| Method Summary | |
boolean |
add(java.lang.Object x)
Append (adds) the argument to the end of this list. |
void |
addFirst(java.lang.Object x)
Inserts the argument as the first element of this list. |
void |
addLast(java.lang.Object x)
Inserts the argument as the last element of this list (note this is the same as the add method, but
is included for symmetry and consistency with addFirst). |
java.lang.Object |
get(int index)
Returns the element at the specified position in this list. |
java.lang.Object |
getFirst()
Returns the first element of this list. |
java.lang.Object |
getLast()
Returns the last element of this list. |
Iterator |
iterator()
Returns an iterator over the elements in this list. |
ListIterator |
listIterator()
Returns a list iterator over the elements in this list. |
java.lang.Object |
removeFirst()
Removes and returns the first element of this list. |
java.lang.Object |
removeLast()
Removes and returns the last element of this list. |
java.lang.Object |
set(int index,
java.lang.Object o)
Replaces the element at the specified position in this list with the specified object. |
int |
size()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
public LinkedList()
| Method Detail |
public boolean add(java.lang.Object x)
List
add in interface Listx - is the element appended to this list.
public int size()
size in interface Listpublic Iterator iterator()
Listnext() first the
element with index zero/0.
iterator in interface Listpublic ListIterator listIterator()
Listnext() first the
element with index zero/0.
listIterator in interface Listpublic void addFirst(java.lang.Object x)
x - is the element added to the front of this listpublic void addLast(java.lang.Object x)
add method, but
is included for symmetry and consistency with addFirst).
x - is the element added to the back of this listpublic java.lang.Object getFirst()
NoSuchElementException - if this list is emptypublic java.lang.Object getLast()
NoSuchElementException - if this list is emptypublic java.lang.Object removeFirst()
NoSuchElementException - if this list is emptypublic java.lang.Object removeLast()
NoSuchElementException - if this list is emptypublic java.lang.Object get(int index)
LinkedList class this method
does not execute in O(1) time.)
get in interface Listindex - is the position of the element returned
java.lang.IndexOutOfBoundsException - if index < 0 || index >=
size()
public java.lang.Object set(int index,
java.lang.Object o)
LinkedList class this method
does not execute in O(1) time.)
set in interface Listindex - is the position of the element that will be
replacedo - is the object to be stored at the specified position
java.lang.IndexOutOfBoundsException - if index < 0 || index >=
size()
|
unofficial documentation for the APCS Java Subset | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||