public class LinkedList<I extends java.lang.Comparable<? super I>> extends java.lang.Object implements ListInterface<I>
| Modifier and Type | Field and Description |
|---|---|
private LinkedListNode<I> |
head |
private int |
listSize |
private LinkedListNode<I> |
tail |
| Constructor and Description |
|---|
LinkedList() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(I obj)
This method is called to add the specified Element to the end of the list.
|
boolean |
add(I obj,
int index)
This method is called to add the specified Element to the list at the given index.
|
void |
addSorted(I obj)
This method is called to add the specified Element to the list in sorted order.
|
I |
get(int index)
This method is called to retrieve the Element 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 Element at the specified index
|
void |
removeAll()
This method removes all Elements 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.
|
private LinkedListNode<I extends java.lang.Comparable<? super I>> head
private LinkedListNode<I extends java.lang.Comparable<? super I>> tail
private int listSize
public void showList()
public int size()
ListInterfacesize in interface ListInterface<I extends java.lang.Comparable<? super I>>public boolean isEmpty()
ListInterfaceisEmpty in interface ListInterface<I extends java.lang.Comparable<? super I>>public void add(I obj)
ListInterfaceadd in interface ListInterface<I extends java.lang.Comparable<? super I>>obj - A reference to the element to be added to the end of the list.
All Elements being added to the list must implement the
Comparable interface.Comparablepublic boolean add(I obj, int index)
ListInterfaceadd in interface ListInterface<I extends java.lang.Comparable<? super I>>obj - A reference to the element to be added to the list.
All Elements being added to the list must implement the
Comparable interface.index - Indicates the position at which to add the specified Element.
Using and index = 0, indicates that the Element being added should
become the head of the list and should succeed even if
the list is currently empty.Comparablepublic void addSorted(I obj)
ListInterfaceaddSorted in interface ListInterface<I extends java.lang.Comparable<? super I>>obj - A reference to the element being added, in sorted order,
to the list. All Elements being added to the list must implement the
Comparable interface.Comparablepublic I get(int index)
ListInterfaceget in interface ListInterface<I extends java.lang.Comparable<? super I>>index - Indicates the position from which to retrieve the Element.public I replace(I obj, int index)
ListInterfacereplace in interface ListInterface<I extends java.lang.Comparable<? super I>>obj - A reference to the element 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 extends java.lang.Comparable<? super I>>index - Indicates the position from which to remove the Element.public void removeAll()
ListInterfaceremoveAll in interface ListInterface<I extends java.lang.Comparable<? super I>>