public class SimpleArrayList extends SimpleAbstractList implements SimpleList
Constructor and Description |
---|
SimpleArrayList() |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
java.lang.Object o)
O(N) time.
|
void |
addFirst(java.lang.Object o)
O(N) time.
|
void |
addLast(java.lang.Object o)
O(1) time, average.
|
void |
clear()
O(1) time.
|
java.lang.Object |
get(int index)
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 the cost of shifting items.
|
java.lang.Object |
removeFirst()
O(N) time because of the cost of shifting items.
|
java.lang.Object |
removeLast()
O(1) time.
|
java.lang.Object |
set(int index,
java.lang.Object o)
O(1) time.
|
void |
shiftLeftInTo(int index)
Shift items to the left one space, into the given location.
|
int |
size()
O(1) time.
|
addAll, contains, getFirst, getLast, indexOf, isEmpty, remove, test, toString
public void shiftLeftInTo(int index)
public 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 add(int index, java.lang.Object o)
add
in interface SimpleList
add
in class SimpleAbstractList
index
- must be >= 0 && <= lengthpublic java.lang.Object remove(int i)
remove
in interface SimpleList
remove
in class SimpleAbstractList
public int size()
size
in interface SimpleList
size
in class SimpleAbstractList
public SimpleIterator iterator()
SimpleList
iterator
in interface SimpleList
iterator
in class SimpleAbstractList
public void clear()
clear
in interface SimpleList
clear
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
index
- must be >= 0 && < lengthpublic java.lang.Object get(int index)
get
in interface SimpleList
get
in class SimpleAbstractList
index
- must be >= 0 && < lengthpublic static void main(java.lang.String[] args)