package mapped;

import java.util.Iterator;
import java.util.NoSuchElementException;
import net.runelite.mapping.Export;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSRuneLiteIterableNodeHashTable;

public class RuneLiteIterableNodeHashTable implements Iterator, RSRuneLiteIterableNodeHashTable {
   @Export("it")
   @ObfuscatedName("it")
   public int field5306;
   @Export("nodeHashTable")
   @ObfuscatedSignature(
      descriptor = "Ltw;"
   )
   public final NodeHashTable nodeHashTable;
   @Export("node")
   @ObfuscatedSignature(
      descriptor = "Lsh;"
   )
   public Node node;

   @ObfuscatedSignature(
      descriptor = "(Ltw;)V"
   )
   public RuneLiteIterableNodeHashTable(NodeHashTable var1) {
      this.nodeHashTable = var1;
   }

   @Export("next")
   @ObfuscatedSignature(
      descriptor = "()Lsh;"
   )
   public Node next() {
      Node var1;
      if(this.field5306 > 0 && this.nodeHashTable.buckets[this.field5306 - 1] != this.node) {
         var1 = this.node;
         this.node = var1.previous;
         return var1;
      } else {
         while(this.field5306 < this.nodeHashTable.size) {
            var1 = this.nodeHashTable.buckets[this.field5306++];
            Node var2 = var1.previous;
            if(var1 != var2) {
               this.node = var2.previous;
               return var2;
            }
         }

         throw new NoSuchElementException();
      }
   }

   @Export("hasNext")
   public boolean hasNext() {
      if(this.field5306 > 0 && this.nodeHashTable.buckets[this.field5306 - 1] != this.node) {
         return true;
      } else {
         for(int var1 = this.field5306; var1 < this.nodeHashTable.size; ++var1) {
            Node var2 = this.nodeHashTable.buckets[var1];
            Node var3 = var2.previous;
            if(var2 != var3) {
               return true;
            }
         }

         return false;
      }
   }
}
