Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public class LinkedList<E> {
  2. // the first element of this LinkedList
  3. private Node start;
  4.  
  5. // the last element of this LinkedList
  6. private Node end;
  7.  
  8. // the number of elements that constitute this LinkedList
  9. private int length;
  10.  
  11. private class Node {
  12. private Node last;
  13. private Node next;
  14.  
  15. private E data;
  16.  
  17. // each Node has a reference to the previous Node and
  18. // the next Node. The first element of the LinkedList
  19. // will have a null reference to the previous element
  20. // and the last element will have a null reference to
  21. // the next element. Each Node stores a piece of data
  22. // in the data variable.
  23. }
  24.  
  25. public void clear() {
  26. start = null;
  27. end = null;
  28.  
  29. length = 0;
  30. }
  31.  
  32. // other methods omitted
  33. }
  34.  
  35. LinkedList
  36. | |
  37.  
  38. Node1 Node2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement