public interface BasicList<E>
extends java.lang.Iterable<E>
Modifier and Type | Method and Description |
---|---|
void |
add(E element)
Adds the specfied element to the logical end of the list.
|
void |
add(int index,
E element)
Adds (inserts) the specfied element at the specfied index of the list
- note that it does not overwrite any existing data at that location.
|
BasicListIterator<E> |
basicListIterator()
Returns a reference to a BasicListIterator over the elements in this list
in the proper sequence (first-to-last order).
|
void |
clear()
Clears the list of its contents - the list should be in the same state
it is after being constructed with the default constructor.
|
boolean |
contains(E element)
Using the provided element's equals method, this method determines
if the list contains the specified element or not.
|
E |
get(int index)
Returns a reference to the element at the specified index.
|
int |
indexOf(E element)
Using the provided element's equals method, this method returns the
index of the first element in the list that is equal to the provided
element, if any.
|
java.util.Iterator<E> |
iterator()
Returns a reference to a java.util.Iterator over the elements of this
list in the proper sequence (first-to-last order).
|
E |
remove(int index)
Removes (and returns) the specified element from the list.
|
E |
set(int index,
E element)
Replaces the element at the specified index with the specified element.
|
int |
size()
The logical size of the list (the number of elements that have been
added and not removed).
|
void add(E element)
element
- The element to add to the logical end of the list.void add(int index, E element)
index
- The index to add (insert) the specfied element.element
- The element to add (insert) to the speficfied position.java.lang.IndexOutOfBoundsException
- when the specified index is
negative or past the logical end of the list.BasicListIterator<E> basicListIterator()
void clear()
boolean contains(E element)
element
- The element to search for in the list.E get(int index)
index
- The index of the element you want to get.java.lang.IndexOutOfBoundsException
- Thrown when the specified index is
negative or past the logical end of the list.int indexOf(E element)
element
- The element to search for.java.util.NoSuchElementException
- if the list does not contain
the specified element.java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
E remove(int index)
index
- The index of the element you want to remove.java.lang.IndexOutOfBoundsException
- Thown when the specified index is
negative or past the logical end of the list.E set(int index, E element)
index
- The index of the element whose value you want to set
(change).java.lang.IndexOutOfBoundsException
- Thown when the specified index is
negative or past the logical end of the list.int size()