home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / util / HashMap$HashIterator.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  1.5 KB  |  91 lines

  1. package java.util;
  2.  
  3. class HashMap$HashIterator implements Iterator {
  4.    HashMap.Entry[] table;
  5.    int index;
  6.    HashMap.Entry entry;
  7.    HashMap.Entry lastReturned;
  8.    int type;
  9.    private int expectedModCount;
  10.    // $FF: synthetic field
  11.    private final HashMap this$0;
  12.  
  13.    HashMap$HashIterator(HashMap var1, int var2) {
  14.       this.this$0 = var1;
  15.       this.table = HashMap.access$200(this.this$0);
  16.       this.index = this.table.length;
  17.       this.entry = null;
  18.       this.lastReturned = null;
  19.       this.expectedModCount = HashMap.access$300(this.this$0);
  20.       this.type = var2;
  21.    }
  22.  
  23.    public boolean hasNext() {
  24.       HashMap.Entry var1 = this.entry;
  25.       int var2 = this.index;
  26.  
  27.       for(HashMap.Entry[] var3 = this.table; var1 == null && var2 > 0; var1 = var3[var2]) {
  28.          --var2;
  29.       }
  30.  
  31.       this.entry = var1;
  32.       this.index = var2;
  33.       return var1 != null;
  34.    }
  35.  
  36.    public Object next() {
  37.       if (HashMap.access$300(this.this$0) != this.expectedModCount) {
  38.          throw new ConcurrentModificationException();
  39.       } else {
  40.          HashMap.Entry var1 = this.entry;
  41.          int var2 = this.index;
  42.  
  43.          for(HashMap.Entry[] var3 = this.table; var1 == null && var2 > 0; var1 = var3[var2]) {
  44.             --var2;
  45.          }
  46.  
  47.          this.entry = var1;
  48.          this.index = var2;
  49.          if (var1 != null) {
  50.             HashMap.Entry var4 = this.lastReturned = this.entry;
  51.             this.entry = var4.next;
  52.             return this.type == 0 ? var4.key : (this.type == 1 ? var4.value : var4);
  53.          } else {
  54.             throw new NoSuchElementException();
  55.          }
  56.       }
  57.    }
  58.  
  59.    public void remove() {
  60.       if (this.lastReturned == null) {
  61.          throw new IllegalStateException();
  62.       } else if (HashMap.access$300(this.this$0) != this.expectedModCount) {
  63.          throw new ConcurrentModificationException();
  64.       } else {
  65.          HashMap.Entry[] var1 = HashMap.access$200(this.this$0);
  66.          int var2 = (this.lastReturned.hash & Integer.MAX_VALUE) % var1.length;
  67.          HashMap.Entry var3 = var1[var2];
  68.  
  69.          for(HashMap.Entry var4 = null; var3 != null; var3 = var3.next) {
  70.             if (var3 == this.lastReturned) {
  71.                HashMap.access$308(this.this$0);
  72.                ++this.expectedModCount;
  73.                if (var4 == null) {
  74.                   var1[var2] = var3.next;
  75.                } else {
  76.                   var4.next = var3.next;
  77.                }
  78.  
  79.                HashMap.access$110(this.this$0);
  80.                this.lastReturned = null;
  81.                return;
  82.             }
  83.  
  84.             var4 = var3;
  85.          }
  86.  
  87.          throw new ConcurrentModificationException();
  88.       }
  89.    }
  90. }
  91.