Class 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-23, BSD License, Leo Woerteler
    • Constructor Detail

      • MinHeap

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

      • 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