public class LinkedList<I> extends java.lang.Object implements ListInterface<I>
Constructor and Description |
---|
LinkedList() |
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 void showList()
public int size()
ListInterface
size
in interface ListInterface<I>
public boolean isEmpty()
ListInterface
isEmpty
in interface ListInterface<I>
public void add(I obj)
ListInterface
add
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.Comparable
public boolean add(I obj, int index)
ListInterface
add
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.Comparable
public boolean addSorted(I obj)
ListInterface
addSorted
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.Comparable
public I get(int index)
ListInterface
get
in interface ListInterface<I>
index
- Indicates the position from which to retrieve the object.public I replace(I obj, int index)
ListInterface
replace
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)
ListInterface
remove
in interface ListInterface<I>
index
- Indicates the position from which to remove the object.public void removeAll()
ListInterface
removeAll
in interface ListInterface<I>