Class MinHeap<K,V>

java.lang.Object
org.basex.util.MinHeap<K,V>
Type Parameters:
K - key type
V - value type

public final class MinHeap<K,V> extends Object
A min-heap.
Author:
BaseX Team 2005-21, BSD License, Leo Woerteler
  • Constructor Details

    • MinHeap

      public MinHeap(Comparator<K> comp)
      Constructs a heap with the given initial capacity and order.
      Parameters:
      comp - comparator
  • Method Details

    • insert

      public void insert(K key, V value)
      Inserts the given key/value pair into the heap.
      Parameters:
      key - key
      value - value
    • removeMin

      public V removeMin()
      Removes the minimum from this heap.
      Returns:
      the removed entry's value
    • size

      public int size()
      Size of this heap.
      Returns:
      number of entries
    • isEmpty

      public boolean isEmpty()
      Checks if this heap is empty.
      Returns:
      true if heap is empty, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object