Interface ObjectHeap<K>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  ObjectHeap.UnsortedIter<K>
      Unsorted iterator - in heap order.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void add​(K key)
      Add a key-value pair to the heap
      void add​(K key, int max)
      Add a key-value pair to the heap, except if the new element is larger than the top, and we are at design size (overflow)
      void clear()
      Delete all elements from the heap.
      boolean isEmpty()
      Is the heap empty?
      K peek()
      Get the current top key
      K poll()
      Remove the first element
      K replaceTopElement​(K e)
      Combined operation that removes the top element, and inserts a new element instead.
      int size()
      Query the size
      ObjectHeap.UnsortedIter<K> unsortedIter()
      Get an unsorted iterator to inspect the heap.
    • Method Detail

      • add

        void add​(K key)
        Add a key-value pair to the heap
        Parameters:
        key - Key
      • add

        void add​(K key,
                 int max)
        Add a key-value pair to the heap, except if the new element is larger than the top, and we are at design size (overflow)
        Parameters:
        key - Key
        max - Maximum size of heap
      • replaceTopElement

        K replaceTopElement​(K e)
        Combined operation that removes the top element, and inserts a new element instead.
        Parameters:
        e - New element to insert
        Returns:
        Previous top element of the heap
      • peek

        K peek()
        Get the current top key
        Returns:
        Top key
      • poll

        K poll()
        Remove the first element
        Returns:
        Top element
      • clear

        void clear()
        Delete all elements from the heap.
      • size

        int size()
        Query the size
        Returns:
        Size
      • isEmpty

        boolean isEmpty()
        Is the heap empty?
        Returns:
        true when the size is 0.
      • unsortedIter

        ObjectHeap.UnsortedIter<K> unsortedIter()
        Get an unsorted iterator to inspect the heap.
        Returns:
        Iterator