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