Package mindustry.ai

Class PathfindQueue

java.lang.Object
mindustry.ai.PathfindQueue

public class PathfindQueue extends Object
A priority queue.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int[]
    Priority queue represented as a balanced binary heap: the two children of queue[n] are queue[2*n+1] and queue[2*(n+1)].
    int
    The number of elements in the priority queue.
    float[]
    Weights of each object in the queue.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    PathfindQueue(int initialCapacity)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(int e, float weight)
    Inserts the specified element into this priority queue.
    void
    Removes all of the elements from this priority queue.
    boolean
     
    int
    Retrieves, but does not remove, the head of this queue.
    int
    Retrieves and removes the head of this queue, or returns null if this queue is empty.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • queue

      public int[] queue
      Priority queue represented as a balanced binary heap: the two children of queue[n] are queue[2*n+1] and queue[2*(n+1)]. The priority queue is ordered by the elements' natural ordering: For each node n in the heap and each descendant d of n, n <= d. The element with the lowest value is in queue[0], assuming the queue is nonempty.
    • weights

      public float[] weights
      Weights of each object in the queue.
    • size

      public int size
      The number of elements in the priority queue.
  • Constructor Details

    • PathfindQueue

      public PathfindQueue()
    • PathfindQueue

      public PathfindQueue(int initialCapacity)
  • Method Details

    • empty

      public boolean empty()
    • add

      public boolean add(int e, float weight)
      Inserts the specified element into this priority queue. If uniqueness is enabled and this priority queue already contains the element, the call leaves the queue unchanged and returns false.
      Returns:
      true if the element was added to this queue, else false
      Throws:
      ClassCastException - if the specified element cannot be compared with elements currently in this priority queue according to the priority queue's ordering
      IllegalArgumentException - if the specified element is null
    • peek

      public int peek()
      Retrieves, but does not remove, the head of this queue. If this queue is empty, 0 is returned.
      Returns:
      the head of this queue
    • clear

      public void clear()
      Removes all of the elements from this priority queue. The queue will be empty after this call returns.
    • poll

      public int poll()
      Retrieves and removes the head of this queue, or returns null if this queue is empty.
      Returns:
      the head of this queue, or null if this queue is empty.