home *** CD-ROM | disk | FTP | other *** search
- package netscape.util;
-
- class HashtableEnumerator implements Enumeration {
- boolean keyEnum;
- int index;
- int returnedCount;
- Hashtable table;
-
- HashtableEnumerator(Hashtable var1, boolean var2) {
- this.table = var1;
- this.keyEnum = var2;
- this.returnedCount = 0;
- if (var1.keys != null) {
- this.index = var1.keys.length;
- } else {
- this.index = 0;
- }
- }
-
- public boolean hasMoreElements() {
- return this.returnedCount < this.table.count;
- }
-
- public Object nextElement() {
- --this.index;
-
- while(this.index >= 0 && this.table.elements[this.index] == null) {
- --this.index;
- }
-
- if (this.index >= 0 && this.returnedCount < this.table.count) {
- ++this.returnedCount;
- return this.keyEnum ? this.table.keys[this.index] : this.table.elements[this.index];
- } else {
- throw new NoSuchElementException();
- }
- }
- }
-