Class ListAsLinkedList
java.lang.Object
|
+--ListAsLinkedList
- public class ListAsLinkedList
- extends java.lang.Object
Class ListAsLinkedList illustrates the O(1) running time for the
putFirst method in an linked list implementation of a list.
Method Summary |
void |
clear()
Clear out all of the elements of this. |
void |
putFirst(java.lang.Object element)
Add the given element to the front of this. |
void |
sort()
Sort this in ascending order, based on the ordering defined by the
compareTo method applied this' elements. |
protected void |
swapNodeValues(ListAsLinkedList.ListNode n1,
ListAsLinkedList.ListNode n2)
Swap the values in the given two nodes. |
java.lang.String |
toString()
Convert this to a space-delimited string of its elements. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ListAsLinkedList
public ListAsLinkedList()
- Construct an empty list.
putFirst
public void putFirst(java.lang.Object element)
- Add the given element to the front of this.
clear
public void clear()
- Clear out all of the elements of this.
sort
public void sort()
- Sort this in ascending order, based on the ordering defined by the
compareTo method applied this' elements. Return the sorted value of
this.
swapNodeValues
protected void swapNodeValues(ListAsLinkedList.ListNode n1,
ListAsLinkedList.ListNode n2)
- Swap the values in the given two nodes. The nodes themselves stay put.
toString
public java.lang.String toString()
- Convert this to a space-delimited string of its elements.
- Overrides:
toString
in class java.lang.Object