Package org.rsbot.script.internal.wrappers

Source Code of org.rsbot.script.internal.wrappers.StatusQueue

package org.rsbot.script.internal.wrappers;

import org.rsbot.client.StatusNode;
import org.rsbot.client.StatusNodeList;

class StatusQueue {
  private final StatusNodeList statusNodeList;
  private StatusNode c_node;

  public StatusQueue(final StatusNodeList statusNodeList) {
    this.statusNodeList = statusNodeList;
  }

  public StatusNode getFirst() {
    final StatusNode node = statusNodeList.getHead().getNext();
    if (node == statusNodeList.getHead()) {
      c_node = null;
      return null;
    }
    c_node = node.getNext();
    return node;
  }

  public StatusNode getLast() {
    final StatusNode node = statusNodeList.getHead().getPrevious();
    if (node == statusNodeList.getHead()) {
      c_node = null;
      return null;
    }
    c_node = node.getPrevious();
    return node;
  }

  public StatusNode getNext() {
    final StatusNode node = c_node;
    if (node == statusNodeList.getHead() || node == null) {
      c_node = null;
      return null;
    }
    c_node = node.getNext();
    return node;
  }

  public StatusNode getPrevious() {
    final StatusNode node = c_node;
    if (node == statusNodeList.getHead() || node == null) {
      c_node = null;
      return null;
    }
    c_node = node.getNext();
    return node;
  }

  public int size() {
    int size = 0;
    StatusNode node = statusNodeList.getHead().getPrevious();
    while (node != statusNodeList.getHead()) {
      node = node.getPrevious();
      size++;
    }
    return size;
  }
}
TOP

Related Classes of org.rsbot.script.internal.wrappers.StatusQueue

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.