home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / misc / CacheEnumerator.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.1 KB  |  58 lines

  1. package sun.misc;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.NoSuchElementException;
  5.  
  6. class CacheEnumerator implements Enumeration {
  7.    boolean keys;
  8.    int index;
  9.    CacheEntry[] table;
  10.    CacheEntry entry;
  11.  
  12.    CacheEnumerator(CacheEntry[] var1, boolean var2) {
  13.       this.table = var1;
  14.       this.keys = var2;
  15.       this.index = var1.length;
  16.    }
  17.  
  18.    public boolean hasMoreElements() {
  19.       while(this.index >= 0) {
  20.          while(this.entry != null) {
  21.             if (this.entry.check() != null) {
  22.                return true;
  23.             }
  24.  
  25.             this.entry = this.entry.next;
  26.          }
  27.  
  28.          while(--this.index >= 0 && (this.entry = this.table[this.index]) == null) {
  29.          }
  30.       }
  31.  
  32.       return false;
  33.    }
  34.  
  35.    public Object nextElement() {
  36.       while(this.index >= 0) {
  37.          if (this.entry == null) {
  38.             while(--this.index >= 0 && (this.entry = this.table[this.index]) == null) {
  39.             }
  40.          }
  41.  
  42.          if (this.entry != null) {
  43.             CacheEntry var1 = this.entry;
  44.             this.entry = var1.next;
  45.             if (((Ref)var1).check() != null) {
  46.                if (this.keys) {
  47.                   return var1.key;
  48.                }
  49.  
  50.                return ((Ref)var1).check();
  51.             }
  52.          }
  53.       }
  54.  
  55.       throw new NoSuchElementException("CacheEnumerator");
  56.    }
  57. }
  58.