package mapped;

import java.util.Iterator;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSIterableNodeDequeDescendingIterator;

@ObfuscatedName("pk")
public class IterableNodeDequeDescendingIterator implements Iterator, RSIterableNodeDequeDescendingIterator {
   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "Lpm;"
   )
   IterableNodeDeque deque;
   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "Lsh;"
   )
   Node field4437;
   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "Lsh;"
   )
   Node last;

   @ObfuscatedSignature(
      descriptor = "(Lpm;)V"
   )
   IterableNodeDequeDescendingIterator(IterableNodeDeque var1) {
      this.last = null;
      this.method7282(var1);
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Lpm;)V"
   )
   void method7282(IterableNodeDeque var1) {
      this.deque = var1;
      this.start_base();
   }

   @ObfuscatedName("ah")
   void start_base() {
      this.field4437 = this.deque != null?this.deque.sentinel.previous:null;
      this.last = null;
   }

   public boolean hasNext() {
      return this.deque.sentinel != this.field4437 && this.field4437 != null;
   }

   public void remove() {
      if(this.last == null) {
         throw new IllegalStateException();
      } else {
         this.last.remove_base();
         this.last = null;
      }
   }

   public Object next() {
      Node var1 = this.field4437;
      if(var1 == this.deque.sentinel) {
         var1 = null;
         this.field4437 = null;
      } else {
         this.field4437 = var1.previous;
      }

      this.last = var1;
      return var1;
   }
}
