Package org.jheaps

Interface Heap<K>

Type Parameters:
K - the type of keys maintained by this heap
All Known Subinterfaces:
DoubleEndedHeap<K>, DoubleEndedValueHeap<K,V>, MergeableHeap<K>, ValueHeap<K,V>
All Known Implementing Classes:
AbstractArrayHeap, AbstractArrayWeakHeap, AbstractRadixHeap, BigIntegerRadixHeap, BinaryArrayBulkInsertWeakHeap, BinaryArrayHeap, BinaryArrayIntegerValueHeap, BinaryArrayWeakHeap, BinaryTreeSoftHeap, DaryArrayHeap, DoubleRadixHeap, IntegerRadixHeap, LongRadixHeap, MinMaxBinaryArrayDoubleEndedHeap

public interface Heap<K>
A heap.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear all the elements of this heap.
    Comparator<? super K>
    Returns the comparator used to order the keys in this heap, or null if this heap uses the natural ordering of its keys.
    Delete and return an element with the minimum key.
    Find an element with the minimum key.
    void
    insert(K key)
    Insert a key into the heap.
    boolean
    Returns true if this heap is empty.
    long
    Returns the number of elements in this heap.
  • Method Details

    • comparator

      Comparator<? super K> comparator()
      Returns the comparator used to order the keys in this heap, or null if this heap uses the natural ordering of its keys.
      Returns:
      the comparator used to order the keys in this heap, or null if this heap uses the natural ordering of its keys
    • insert

      void insert(K key)
      Insert a key into the heap.
      Parameters:
      key - the key to insert
    • findMin

      K findMin()
      Find an element with the minimum key.
      Returns:
      an element with the minimum key
      Throws:
      NoSuchElementException - if the heap is empty
    • deleteMin

      K deleteMin()
      Delete and return an element with the minimum key. If multiple such elements exists, only one of them will be deleted.
      Returns:
      the deleted element with the minimum key
      Throws:
      NoSuchElementException - if the heap is empty
    • isEmpty

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

      long size()
      Returns the number of elements in this heap.
      Returns:
      the number of elements in this heap
    • clear

      void clear()
      Clear all the elements of this heap.