| Constructor and Description |
|---|
MysteryListImplementation()
Constructs an empty list.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int newPosition,
T newItem)
Adds newItem at the given index.
|
void |
add(T newItem)
Adds newItem to the end of the list.
|
T |
at(int position)
Returns the item at a given index.
|
void |
clear()
Removes all items from the list.
|
boolean |
contains(T targetItem)
Returns true if the list contains the target item.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
boolean |
isEmpty()
Returns true if the list is empty.
|
java.util.Iterator<T> |
iterator()
Returns an iterator that begins just before index 0 in this list.
|
int |
length()
Returns the length of the list.
|
T |
remove(int position)
Removes the item at the given index, and returns it.
|
void |
replace(int position,
T newItem)
Replaces the item at a given index.
|
java.lang.Object[] |
toArray()
Returns an array version of the list.
|
java.lang.String |
toString() |
public MysteryListImplementation()
public void add(T newItem)
Listpublic void add(int newPosition,
T newItem)
Listpublic T remove(int position)
Listpublic void clear()
Listpublic T at(int position)
Listpublic void replace(int position,
T newItem)
Listpublic boolean contains(T targetItem)
Listpublic int length()
Listpublic boolean isEmpty()
Listpublic java.lang.Object[] toArray()
Listpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object