Package minpq

Class HeapMinPQ<T>

    • Constructor Detail

      • HeapMinPQ

        public HeapMinPQ()
        Constructs an empty instance.
    • Method Detail

      • add

        public void add​(T item,
                        double priority)
        Description copied from interface: ExtrinsicMinPQ
        Adds an item with the given priority value.
        Specified by:
        add in interface ExtrinsicMinPQ<T>
        Parameters:
        item - the element to add.
        priority - the priority value for the item.
      • contains

        public boolean contains​(T item)
        Description copied from interface: ExtrinsicMinPQ
        Returns true if the given item is in this priority queue.
        Specified by:
        contains in interface ExtrinsicMinPQ<T>
        Parameters:
        item - element to be checked for containment.
        Returns:
        true if the given item is in this priority queue.
      • peekMin

        public T peekMin()
        Description copied from interface: ExtrinsicMinPQ
        Returns the item with the minimum priority value.
        Specified by:
        peekMin in interface ExtrinsicMinPQ<T>
        Returns:
        the item with the minimum priority value.
      • removeMin

        public T removeMin()
        Description copied from interface: ExtrinsicMinPQ
        Returns and removes the item with the minimum priority value.
        Specified by:
        removeMin in interface ExtrinsicMinPQ<T>
        Returns:
        the item with the minimum priority value.
      • changePriority

        public void changePriority​(T item,
                                   double priority)
        Description copied from interface: ExtrinsicMinPQ
        Updates the given items' associated priority value.
        Specified by:
        changePriority in interface ExtrinsicMinPQ<T>
        Parameters:
        item - the element whose associated priority value should be modified.
        priority - the updated priority value.
      • size

        public int size()
        Description copied from interface: ExtrinsicMinPQ
        Returns the number of items in this priority queue.
        Specified by:
        size in interface ExtrinsicMinPQ<T>
        Returns:
        the number of elements in this priority queue.