public interface ListInterface<T>
Modifier and Type | Method and Description |
---|---|
void |
add(int newPosition,
T newEntry)
Adds a new entry at a specified position within this list.
|
void |
add(T newEntry)
Adds a new entry to the end of this list.
|
void |
clear()
Removes all entries from this list.
|
boolean |
contains(T anEntry)
Sees whether this list contains a given entry.
|
T |
getEntry(int givenPosition)
Retrieves the entry at a given position in this list.
|
int |
getLength()
Gets the length of this list.
|
boolean |
isEmpty()
Sees whether this list is empty.
|
T |
remove(int givenPosition)
Removes the entry at a given position from this list.
|
T |
replace(int givenPosition,
T newEntry)
Replaces the entry at a given position in this list.
|
java.lang.Object[] |
toArray()
Retrieves all entries that are in this list in the order in which they
occur in the list.
|
void add(T newEntry)
newEntry
- The object to be added as a new entry.void add(int newPosition, T newEntry)
newPosition
- An integer that specifies the desired position of the new
entry.newEntry
- The object to be added as a new entry.java.lang.IndexOutOfBoundsException
- if either newPosition less than 0 or newPosition greater than
getLength() + 1.T remove(int givenPosition)
givenPosition
- An integer that indicates the position of the entry to be
removed.java.lang.IndexOutOfBoundsException
- if either givenPosition less than 0 or givenPosition greater
than getLength().void clear()
T replace(int givenPosition, T newEntry)
givenPosition
- An integer that indicates the position of the entry to be
replaced.newEntry
- The object that will replace the entry at the position
givenPosition.java.lang.IndexOutOfBoundsException
- if either givenPosition less than 0 or givenPosition greater
than getLength().T getEntry(int givenPosition)
givenPosition
- An integer that indicates the position of the desired entry.java.lang.IndexOutOfBoundsException
- if either givenPosition less than 0 or givenPosition greater
than getLength().java.lang.Object[] toArray()
boolean contains(T anEntry)
anEntry
- The object that is the desired entry.int getLength()
boolean isEmpty()