home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / java / util / LinkedList$ListItr.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.3 KB  |  109 lines

  1. package java.util;
  2.  
  3. class LinkedList$ListItr implements ListIterator {
  4.    private LinkedList.Entry lastReturned;
  5.    private LinkedList.Entry next;
  6.    private int nextIndex;
  7.    private int expectedModCount;
  8.    // $FF: synthetic field
  9.    private final LinkedList this$0;
  10.  
  11.    LinkedList$ListItr(LinkedList var1, int var2) {
  12.       this.this$0 = var1;
  13.       this.lastReturned = LinkedList.access$000(this.this$0);
  14.       this.expectedModCount = this.this$0.modCount;
  15.       if (var2 >= 0 && var2 <= LinkedList.access$100(var1)) {
  16.          if (var2 < LinkedList.access$100(var1) / 2) {
  17.             this.next = LinkedList.access$000(var1).next;
  18.  
  19.             for(this.nextIndex = 0; this.nextIndex < var2; ++this.nextIndex) {
  20.                this.next = this.next.next;
  21.             }
  22.          } else {
  23.             this.next = LinkedList.access$000(var1);
  24.  
  25.             for(this.nextIndex = LinkedList.access$100(var1); this.nextIndex > var2; --this.nextIndex) {
  26.                this.next = this.next.previous;
  27.             }
  28.          }
  29.  
  30.       } else {
  31.          throw new IndexOutOfBoundsException("Index: " + var2 + ", Size: " + LinkedList.access$100(var1));
  32.       }
  33.    }
  34.  
  35.    public boolean hasNext() {
  36.       return this.nextIndex != LinkedList.access$100(this.this$0);
  37.    }
  38.  
  39.    public Object next() {
  40.       this.checkForComodification();
  41.       if (this.nextIndex == LinkedList.access$100(this.this$0)) {
  42.          throw new NoSuchElementException();
  43.       } else {
  44.          this.lastReturned = this.next;
  45.          this.next = this.next.next;
  46.          ++this.nextIndex;
  47.          return this.lastReturned.element;
  48.       }
  49.    }
  50.  
  51.    public boolean hasPrevious() {
  52.       return this.nextIndex != 0;
  53.    }
  54.  
  55.    public Object previous() {
  56.       if (this.nextIndex == 0) {
  57.          throw new NoSuchElementException();
  58.       } else {
  59.          this.lastReturned = this.next = this.next.previous;
  60.          --this.nextIndex;
  61.          this.checkForComodification();
  62.          return this.lastReturned.element;
  63.       }
  64.    }
  65.  
  66.    public int nextIndex() {
  67.       return this.nextIndex;
  68.    }
  69.  
  70.    public int previousIndex() {
  71.       return this.nextIndex - 1;
  72.    }
  73.  
  74.    public void remove() {
  75.       LinkedList.access$200(this.this$0, this.lastReturned);
  76.       if (this.next == this.lastReturned) {
  77.          this.next = this.lastReturned.next;
  78.       } else {
  79.          --this.nextIndex;
  80.       }
  81.  
  82.       this.lastReturned = LinkedList.access$000(this.this$0);
  83.       ++this.expectedModCount;
  84.    }
  85.  
  86.    public void set(Object var1) {
  87.       if (this.lastReturned == LinkedList.access$000(this.this$0)) {
  88.          throw new IllegalStateException();
  89.       } else {
  90.          this.checkForComodification();
  91.          this.lastReturned.element = var1;
  92.       }
  93.    }
  94.  
  95.    public void add(Object var1) {
  96.       this.checkForComodification();
  97.       this.lastReturned = LinkedList.access$000(this.this$0);
  98.       LinkedList.access$300(this.this$0, var1, this.next);
  99.       ++this.nextIndex;
  100.       ++this.expectedModCount;
  101.    }
  102.  
  103.    final void checkForComodification() {
  104.       if (this.this$0.modCount != this.expectedModCount) {
  105.          throw new ConcurrentModificationException();
  106.       }
  107.    }
  108. }
  109.