|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uwcse.collections.SimpleAbstractList | +--uwcse.collections.SimpleLinkedList
An implementation of SimpleList, using a circular, doubly-linked list, without dummy (header) nodes. Generally, this collection performs adds to the front and back efficiently, but does not support random access operations efficiently.
Constructor Summary | |
SimpleLinkedList()
|
Method Summary | |
void |
add(int index,
java.lang.Object o)
O(N) time, because of the cost of finding the location to add. |
void |
addFirst(java.lang.Object o)
O(1) time. |
void |
addLast(java.lang.Object o)
O(1) time. |
void |
clear()
O(1) time. |
java.lang.Object |
get(int index)
O(N) time because we need to walk N links |
boolean |
isEmpty()
O(1) time. |
SimpleIterator |
iterator()
Answer an iterator over the elements of the list. |
static void |
main(java.lang.String[] args)
|
java.lang.Object |
remove(int i)
O(N) time, because of the cost of finding the location to remove. |
java.lang.Object |
removeFirst()
O(1) time. |
java.lang.Object |
removeLast()
O(1) time. |
java.lang.Object |
set(int index,
java.lang.Object o)
O(N) time because of the cost of finding the location. |
int |
size()
O(1) time, because we keep a count. |
Methods inherited from class uwcse.collections.SimpleAbstractList |
addAll, contains, getFirst, getLast, indexOf, remove, test, toString |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface uwcse.collections.SimpleList |
addAll, contains, getFirst, getLast, indexOf, remove |
Constructor Detail |
public SimpleLinkedList()
Method Detail |
public void add(int index, java.lang.Object o)
add
in interface SimpleList
add
in class SimpleAbstractList
uwcse.collections.SimpleList
index
- must be >= 0 && <= lengthpublic void addFirst(java.lang.Object o)
addFirst
in interface SimpleList
addFirst
in class SimpleAbstractList
public void addLast(java.lang.Object o)
addLast
in interface SimpleList
addLast
in class SimpleAbstractList
public void clear()
clear
in interface SimpleList
clear
in class SimpleAbstractList
public java.lang.Object get(int index)
get
in interface SimpleList
get
in class SimpleAbstractList
uwcse.collections.SimpleList
index
- must be >= 0 && < lengthpublic boolean isEmpty()
isEmpty
in interface SimpleList
isEmpty
in class SimpleAbstractList
public SimpleIterator iterator()
SimpleList
iterator
in interface SimpleList
iterator
in class SimpleAbstractList
public static void main(java.lang.String[] args)
public java.lang.Object remove(int i)
remove
in interface SimpleList
remove
in class SimpleAbstractList
public java.lang.Object removeFirst()
removeFirst
in interface SimpleList
removeFirst
in class SimpleAbstractList
public java.lang.Object removeLast()
removeLast
in interface SimpleList
removeLast
in class SimpleAbstractList
public java.lang.Object set(int index, java.lang.Object o)
set
in interface SimpleList
set
in class SimpleAbstractList
uwcse.collections.SimpleList
index
- must be >= 0 && < lengthpublic int size()
size
in interface SimpleList
size
in class SimpleAbstractList
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |