1 7 8 16 17 package com.sun.corba.se.impl.util; 18 19 import java.util.Dictionary ; 20 import java.util.Enumeration ; 21 import java.util.NoSuchElementException ; 22 23 27 class IdentityHashtableEnumerator implements Enumeration { 28 boolean keys; 29 int index; 30 IdentityHashtableEntry table[]; 31 IdentityHashtableEntry entry; 32 33 IdentityHashtableEnumerator(IdentityHashtableEntry table[], boolean keys) { 34 this.table = table; 35 this.keys = keys; 36 this.index = table.length; 37 } 38 39 public boolean hasMoreElements() { 40 if (entry != null) { 41 return true; 42 } 43 while (index-- > 0) { 44 if ((entry = table[index]) != null) { 45 return true; 46 } 47 } 48 return false; 49 } 50 51 public Object nextElement() { 52 if (entry == null) { 53 while ((index-- > 0) && ((entry = table[index]) == null)); 54 } 55 if (entry != null) { 56 IdentityHashtableEntry e = entry; 57 entry = e.next; 58 return keys ? e.key : e.value; 59 } 60 throw new NoSuchElementException ("IdentityHashtableEnumerator"); 61 } 62 } 63 | Popular Tags |