Package jline.util

Class IndexedMinHeap

java.lang.Object
jline.util.IndexedMinHeap

public class IndexedMinHeap extends Object
IndexedMinHeap A min-heap over a fixed set of integer keys 0..n-1, each associated with a double priority. Supports O(log n) update of any key by index, and O(1) peek at the minimum. Typical use in NRM: keys are reaction indices, priorities are absolute firing times τ_k.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a heap of size n.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Establish heap order after bulk-writing into key[] directly.
    double
    getKey(int k)
    Read the current priority of reaction k.
    int
    Return the index of the reaction with the smallest key.
    double
    Return the smallest key value.
    void
    update(int k, double newKey)
    Update the priority of reaction k and restore heap order.

    Methods inherited from class java.lang.Object

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

    • key

      public final double[] key
  • Constructor Details

    • IndexedMinHeap

      public IndexedMinHeap(int n)
      Construct a heap of size n. All keys initialised to +∞. Bulk-set key[] then call buildHeap(), or call update() individually.
  • Method Details

    • peekMin

      public int peekMin()
      Return the index of the reaction with the smallest key. O(1).
    • peekMinKey

      public double peekMinKey()
      Return the smallest key value. O(1).
    • update

      public void update(int k, double newKey)
      Update the priority of reaction k and restore heap order. O(log n).
    • getKey

      public double getKey(int k)
      Read the current priority of reaction k. O(1).
    • buildHeap

      public void buildHeap()
      Establish heap order after bulk-writing into key[] directly. Runs in O(n) — prefer this over n individual update() calls at init.