Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. // $Id:$
  2. //
  3. // Moritz Kaltenbrunner, mpkalten@ucsc.edu
  4. //
  5.  
  6. class Lex{
  7.  
  8. public static void main(String[] args){
  9. List A = new List();
  10. List B = new List();
  11.  
  12. for(int i=1; i<=20; i++){
  13. A.append(i);
  14. B.prepend(i);
  15. }
  16. System.out.println(A);
  17. System.out.println(B);
  18.  
  19. for(A.moveFront(); A.index()>=0; A.moveNext()){
  20. System.out.print(A.get()+" ");
  21. }
  22. System.out.println();
  23. for(B.moveBack(); B.index()>=0; B.movePrev()){
  24. System.out.print(B.get()+" ");
  25. }
  26. System.out.println();
  27.  
  28. List C = A.copy();
  29. System.out.println(A.equals(B));
  30. System.out.println(B.equals(C));
  31. System.out.println(C.equals(A));
  32.  
  33. A.moveFront();
  34. for(int i=0; i<5; i++) A.moveNext(); // at index 5
  35. A.insertBefore(-1); // at index 6
  36. for(int i=0; i<9; i++) A.moveNext(); // at index 15
  37. A.insertAfter(-2);
  38. for(int i=0; i<5; i++) A.movePrev(); // at index 10
  39. A.delete();
  40. System.out.println(A);
  41. System.out.println(A.length());
  42. A.clear();
  43. System.out.println(A.length());
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement