|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weiss.util.AbstractCollection | +--weiss.util.LinkedList
LinkedList class implements a doubly-linked list.
Constructor Summary | |
LinkedList()
Construct an empty LinkedList. |
|
LinkedList(Collection other)
Construct a LinkedList with same items as another Collection. |
Method Summary | |
void |
add(int idx,
java.lang.Object x)
Adds an item to this collection, at specified position. |
boolean |
add(java.lang.Object x)
Adds an item to this collection, at the end. |
void |
addFirst(java.lang.Object x)
Adds an item to this collection, at front. |
void |
addLast(java.lang.Object x)
Adds an item to this collection, at end. |
void |
clear()
Change the size of this collection to zero. |
boolean |
contains(java.lang.Object x)
Tests if some item is in this collection. |
java.lang.Object |
get(int idx)
Returns the item at position idx. |
java.lang.Object |
getFirst()
Returns the first item in the list. |
java.lang.Object |
getLast()
Returns the last item in the list. |
Iterator |
iterator()
Obtains an Iterator object used to traverse the collection. |
ListIterator |
listIterator(int idx)
Obtains a ListIterator object used to traverse the collection bidirectionally. |
java.lang.Object |
remove(int idx)
Removes an item from this collection. |
boolean |
remove(java.lang.Object x)
Removes an item from this collection. |
java.lang.Object |
removeFirst()
Removes the first item in the list. |
java.lang.Object |
removeLast()
Removes the last item in the list. |
java.lang.Object |
set(int idx,
java.lang.Object newVal)
Changes the item at position idx. |
int |
size()
Returns the number of items in this collection. |
Methods inherited from class weiss.util.AbstractCollection |
equals, hashCode, isEmpty, toArray |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface weiss.util.Collection |
isEmpty, toArray |
Constructor Detail |
public LinkedList()
public LinkedList(Collection other)
Method Detail |
public int size()
size
in interface Collection
public boolean contains(java.lang.Object x)
contains
in interface Collection
contains
in class AbstractCollection
x
- any object.public boolean add(java.lang.Object x)
add
in interface Collection
x
- any object.public void add(int idx, java.lang.Object x)
x
- any object.idx
- position to add at.IndexOutOfBoundsException
- if idx is not between 0 and size(), inclusive.public void addFirst(java.lang.Object x)
x
- any object.public void addLast(java.lang.Object x)
x
- any object.public java.lang.Object getFirst()
NoSuchElementException
- if the list is empty.public java.lang.Object getLast()
NoSuchElementException
- if the list is empty.public java.lang.Object removeFirst()
NoSuchElementException
- if the list is empty.public java.lang.Object removeLast()
NoSuchElementException
- if the list is empty.public boolean remove(java.lang.Object x)
remove
in interface Collection
remove
in class AbstractCollection
x
- any object.public java.lang.Object get(int idx)
get
in interface List
idx
- the index to search in.IndexOutOfBoundsException
- if index is out of range.public java.lang.Object set(int idx, java.lang.Object newVal)
set
in interface List
idx
- the index to change.newVal
- the new value.IndexOutOfBoundsException
- if index is out of range.public java.lang.Object remove(int idx)
idx
- the index of the object.public void clear()
clear
in interface Collection
clear
in class AbstractCollection
public Iterator iterator()
iterator
in interface Collection
public ListIterator listIterator(int idx)
listIterator
in interface List
idx
- the index to start the iterator. Use size() to do complete
reverse traversal. Use 0 to do complete forward traversal.IndexOutOfBoundsException
- if idx is not between 0 and size(), inclusive.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |