Class AbstractArrayHeap<K>

    • Constructor Detail

      • AbstractArrayHeap

        public AbstractArrayHeap​(java.util.Comparator<? super K> comparator,
                                 int capacity)
        Construct a new heap
        Parameters:
        comparator - the comparator to use
        capacity - the initial capacity
    • Method Detail

      • initCapacity

        protected void initCapacity​(int capacity)
        Initialize the array representation
        Specified by:
        initCapacity in class AbstractArrayWeakHeap<K>
        Parameters:
        capacity - the capacity
      • findMin

        public K findMin()
        Find an element with the minimum key.
        Returns:
        an element with the minimum key
      • insert

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

        public 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