public class ArrayBasedList<I> extends java.lang.Object implements ListInterface<I>
| Constructor and Description |
|---|
ArrayBasedList() |
ArrayBasedList(int size) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(I obj)
This method is called to add the specified object to the end of the list.
|
boolean |
add(I obj,
int index)
This method is called to add the specified object to the list at the given index.
|
boolean |
addSorted(I obj)
This method is called to add the specified object to the list in sorted order.
|
I |
get(int index)
This method is called to retrieve the object at the specified index.
|
boolean |
isEmpty()
This method is called to determine if the list is empty.
|
boolean |
remove(int index)
This method is called to remove the object at the specified index
|
void |
removeAll()
This method removes all objects from the list, making the list empty.
|
I |
replace(I obj,
int index)
This method is called to replace the element at the specified index with the specified
obj.
|
void |
showList() |
int |
size()
This method is called to obtain the count of elements in the list.
|
public ArrayBasedList()
public ArrayBasedList(int size)
public void showList()
public int size()
ListInterfacesize in interface ListInterface<I>public boolean isEmpty()
ListInterfaceisEmpty in interface ListInterface<I>public void add(I obj)
ListInterfaceadd in interface ListInterface<I>obj - A reference to the object to be added to the end of the list.
All objects being added to the list must implement the
Comparable interface.Comparablepublic boolean add(I obj, int index)
ListInterfaceadd in interface ListInterface<I>obj - A reference to the object to be added to the list.
All objects being added to the list must implement the
Comparable interface.index - Indicates the position at which to add the specified object.
Using and index = 0, indicates that the object being added should
become the head of the list and should succeed even if
the list is currently empty.Comparablepublic boolean addSorted(I obj)
ListInterfaceaddSorted in interface ListInterface<I>obj - A reference to the obj being added, in sorted order,
to the list. All objects being added to the list must implement the
Comparable interface.Comparablepublic I get(int index)
ListInterfaceget in interface ListInterface<I>index - Indicates the position from which to retrieve the object.public I replace(I obj, int index)
ListInterfacereplace in interface ListInterface<I>obj - A reference to the obj that will replace the current element in the list.index - Idicates the position in the list where the replacement should be made.public boolean remove(int index)
ListInterfaceremove in interface ListInterface<I>index - Indicates the position from which to remove the object.public void removeAll()
ListInterfaceremoveAll in interface ListInterface<I>