public class AList<T> extends java.lang.Object implements ListInterface<T>
| Constructor and Description |
|---|
AList()
AList's default constructor, makes a list with default capacity of 25.
|
AList(int initialCapacity)
AList's constructor where you specify the initial capacity.
|
| 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.
|
boolean |
equals(java.lang.Object obj)
maellis adding these for use in testing.
|
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.
|
java.lang.String |
toString()
maellis adding these for use in testing.
|
public AList()
public AList(int initialCapacity)
initialCapacity - capacity for the list, unless smaller than 25public void add(T newEntry)
add in interface ListInterface<T>newEntry - The object to be added as a new entry.public void add(int newPosition,
T newEntry)
add in interface ListInterface<T>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.public T remove(int givenPosition)
remove in interface ListInterface<T>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().public void clear()
clear in interface ListInterface<T>public T replace(int givenPosition, T newEntry)
replace in interface ListInterface<T>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().public T getEntry(int givenPosition)
getEntry in interface ListInterface<T>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().public java.lang.Object[] toArray()
toArray in interface ListInterface<T>public boolean contains(T anEntry)
contains in interface ListInterface<T>anEntry - The object that is the desired entry.public int getLength()
getLength in interface ListInterface<T>public boolean isEmpty()
isEmpty in interface ListInterface<T>public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the Object to compare this list to