home *** CD-ROM | disk | FTP | other *** search
- package COM.objectspace.jgl;
-
- public final class HashMapIterator implements ForwardIterator {
- public static final int PAIR = 1;
- public static final int KEY = 2;
- public static final int VALUE = 3;
- HashMap myHashMap;
- HashMap.HashMapNode myNode;
- int myMode = 1;
-
- public HashMapIterator() {
- }
-
- public HashMapIterator(HashMapIterator var1) {
- this.myHashMap = var1.myHashMap;
- this.myNode = var1.myNode;
- this.myMode = var1.myMode;
- }
-
- HashMapIterator(HashMap.HashMapNode var1, HashMap var2, int var3) {
- this.myHashMap = var2;
- this.myNode = var1;
- this.myMode = var3;
- }
-
- public Object clone() {
- return new HashMapIterator(this);
- }
-
- public boolean equals(Object var1) {
- if (var1 instanceof HashMapIterator) {
- HashMapIterator var2 = (HashMapIterator)var1;
- if (this.myNode == var2.myNode || false) {
- return true;
- }
- }
-
- return false;
- }
-
- public boolean equals(HashMapIterator var1) {
- return this.myNode == var1.myNode;
- }
-
- public boolean atBegin() {
- for(int var1 = 0; var1 < this.myHashMap.length; ++var1) {
- if (this.myHashMap.buckets[var1] != null) {
- if (this.myNode != this.myHashMap.buckets[var1]) {
- return false;
- }
-
- return true;
- }
- }
-
- return true;
- }
-
- public boolean atEnd() {
- return this.myNode == null;
- }
-
- public boolean hasMoreElements() {
- return this.myNode != null;
- }
-
- public void advance() {
- this.myNode = this.myNode.next != null ? this.myNode.next : this.next(this.myNode);
- }
-
- public void advance(int var1) {
- if (var1 < 0) {
- throw new InvalidOperationException("Attempt to advance a ForwardIterator in the wrong direction.");
- } else {
- while(var1-- > 0) {
- this.advance();
- }
-
- }
- }
-
- public Object nextElement() {
- Object var1 = null;
- switch (this.myMode) {
- case 1:
- var1 = new Pair(this.myNode.key, this.myNode.value);
- break;
- case 2:
- var1 = this.myNode.key;
- break;
- case 3:
- var1 = this.myNode.value;
- }
-
- this.myNode = this.myNode.next != null ? this.myNode.next : this.next(this.myNode);
- return var1;
- }
-
- public Object get() {
- switch (this.myMode) {
- case 1:
- return new Pair(this.myNode.key, this.myNode.value);
- case 2:
- return this.myNode.key;
- case 3:
- return this.myNode.value;
- default:
- return null;
- }
- }
-
- public void put(Object var1) {
- switch (this.myMode) {
- case 1:
- Pair var2 = (Pair)var1;
- this.myNode.key = var2.first;
- this.myNode.value = var2.second;
- return;
- case 2:
- this.myNode.key = var1;
- return;
- case 3:
- this.myNode.value = var1;
- return;
- default:
- }
- }
-
- public Object key() {
- return this.myNode.key;
- }
-
- public Object value() {
- return this.myNode.value;
- }
-
- public void value(Object var1) {
- this.myNode.value = var1;
- }
-
- public int distance(ForwardIterator var1) {
- HashMap.HashMapNode var2 = this.myNode;
- HashMap.HashMapNode var3 = ((HashMapIterator)var1).myNode;
-
- int var4;
- for(var4 = 0; this.myNode != var3; this.myNode = this.myNode.next != null ? this.myNode.next : this.next(this.myNode)) {
- ++var4;
- }
-
- this.myNode = var2;
- return var4;
- }
-
- private HashMap.HashMapNode next(HashMap.HashMapNode var1) {
- for(int var2 = var1.hash % this.myHashMap.length + 1; var2 < this.myHashMap.length; ++var2) {
- if (this.myHashMap.buckets[var2] != null) {
- return this.myHashMap.buckets[var2];
- }
- }
-
- return null;
- }
-
- public Container getContainer() {
- return this.myHashMap;
- }
- }
-