Interface HeapInterface<E>

Type Parameters:
E - Type of elements stored in this heap
All Known Implementing Classes:
Heap

public interface HeapInterface<E>
A generic heap.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Initial size of the Heap.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(E element)
    Adds the specified element to this heap.
    Returns the comparator used by this heap.
    boolean
    Returns true if there are no elements in this heap, false otherwise.
    Removes and returns the element with the highest priority.
    int
    Returns the number of elements stored in this heap.
  • Field Details

  • Method Details

    • add

      void add(E element)
      Adds the specified element to this heap.
      Parameters:
      element - the element to add to this heap.
    • remove

      E remove() throws EmptyHeapException
      Removes and returns the element with the highest priority.
      Returns:
      element with the highest priority.
      Throws:
      EmptyHeapException - when trying to remove from an empty heap.
    • size

      int size()
      Returns the number of elements stored in this heap.
      Returns:
      number of elements in this heap.
    • isEmpty

      boolean isEmpty()
      Returns true if there are no elements in this heap, false otherwise.
      Returns:
      true if there are no elements in this heap, false otherwise.
    • comparator

      Comparator<E> comparator()
      Returns the comparator used by this heap.
      Returns:
      the comparator used by this heap.