|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uwcse.collections.SimpleAbstractList
An abstract superclass for list implementations. Implements several of the basic operations in terms of operations that are left to concrete implementations
Constructor Summary | |
SimpleAbstractList()
|
Method Summary | |
abstract void |
add(int index,
java.lang.Object o)
Add the given object at the given location, shifting elements as necessary. |
void |
addAll(SimpleList c)
Iterates over the given collection, adding each item to the end of the receiver. |
abstract void |
addFirst(java.lang.Object o)
Add the given object to the front of the list. |
abstract void |
addLast(java.lang.Object o)
Add the given object to the rear of the list. |
abstract void |
clear()
Remove all elements. |
boolean |
contains(java.lang.Object o)
Answers indexOf(o) != -1 |
abstract java.lang.Object |
get(int index)
Answer the element at the given location. |
java.lang.Object |
getFirst()
Answers get(0) |
java.lang.Object |
getLast()
Answers get(size() - 1) |
int |
indexOf(java.lang.Object o)
Iterates over the items, answering the index of the first occurrence of o. |
boolean |
isEmpty()
Answer size() == 0 |
abstract SimpleIterator |
iterator()
Answer an iterator over the elements of the list. |
abstract java.lang.Object |
remove(int i)
Remove the item at the given index, shifting elements as necessary. |
boolean |
remove(java.lang.Object o)
Relies on indexOf(o) and remove(index). |
abstract java.lang.Object |
removeFirst()
Remove the first element. |
abstract java.lang.Object |
removeLast()
Remove the last element. |
abstract java.lang.Object |
set(int index,
java.lang.Object o)
Replace the element at the given location. |
abstract int |
size()
Answer the number of elements in the collection. |
static void |
test(SimpleList list)
A generalized test method which can be used by subclasses. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SimpleAbstractList()
Method Detail |
public abstract void add(int index, java.lang.Object o)
SimpleList
add
in interface SimpleList
uwcse.collections.SimpleList
index
- must be >= 0 && <= lengthpublic void addAll(SimpleList c)
addAll
in interface SimpleList
public abstract void addFirst(java.lang.Object o)
SimpleList
addFirst
in interface SimpleList
public abstract void addLast(java.lang.Object o)
SimpleList
addLast
in interface SimpleList
public abstract void clear()
SimpleList
clear
in interface SimpleList
public boolean contains(java.lang.Object o)
contains
in interface SimpleList
public abstract java.lang.Object get(int index)
SimpleList
get
in interface SimpleList
uwcse.collections.SimpleList
index
- must be >= 0 && < lengthpublic java.lang.Object getFirst()
getFirst
in interface SimpleList
public java.lang.Object getLast()
getLast
in interface SimpleList
public int indexOf(java.lang.Object o)
indexOf
in interface SimpleList
public boolean isEmpty()
SimpleList
isEmpty
in interface SimpleList
public abstract SimpleIterator iterator()
SimpleList
iterator
in interface SimpleList
public abstract java.lang.Object remove(int i)
SimpleList
remove
in interface SimpleList
public boolean remove(java.lang.Object o)
remove
in interface SimpleList
uwcse.collections.SimpleList
public abstract java.lang.Object removeFirst()
SimpleList
removeFirst
in interface SimpleList
public abstract java.lang.Object removeLast()
SimpleList
removeLast
in interface SimpleList
public abstract java.lang.Object set(int index, java.lang.Object o)
SimpleList
set
in interface SimpleList
uwcse.collections.SimpleList
index
- must be >= 0 && < lengthpublic abstract int size()
SimpleList
size
in interface SimpleList
public static void test(SimpleList list)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |