// Path: src/main/java/org/jheaps/Constants.java
// public class Constants {
// 
//     /**
//      * Library name
//      */
//     public static final String NAME = "JHeaps";
// 
//     /**
//      * Global debug flag which affects compiled code
//      */
//     public static final boolean DEBUG = false;
// 
//     /**
//      * Global level one debug flag which affects compiled code.
//      */
//     public static final boolean DEBUG_LEVEL1 = false;
// 
//     /**
//      * Global level two debug flag which affects compiled code
//      */
//     public static final boolean DEBUG_LEVEL2 = false;
// 
//     /**
//      * Global benchmarking flag. This flag enables sanity checks when the code
//      * is not for benchmarking performance. When benchmarking we assume that the
//      * user provided the correct input.
//      */
//     public static final boolean NOT_BENCHMARK = true;
// 
//     private Constants() {
//     }
// 
// }


import java.util.Comparator;
import java.util.NoSuchElementException;
import org.jheaps.Constants;
import org.jheaps.annotations.ConstantTime;
import org.jheaps.annotations.LogarithmicTime;
/*
 * (C) Copyright 2014-2016, by Dimitrios Michail
 *
 * JHeaps Library
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jheaps.array;



/**
 * Abstract implementation of a heap using an array representation.
 * 
 * @author Dimitrios Michail
 *
 * @param <K>
 *            the type of keys maintained by this heap
 */
abstract class AbstractArrayHeap<K> extends AbstractArrayWeakHeap<K> {

    private static final long serialVersionUID = 1L;

    /**
     * Construct a new heap
     * 
     * @param comparator
     *            the comparator to use
     * @param capacity
     *            the initial capacity
     */
    public AbstractArrayHeap(Comparator<? super K> comparator, int capacity) {
        super(comparator, capacity);
    }

    /**
     * Initialize the array representation
     */
    @Override
    @SuppressWarnings("unchecked")
    protected void initCapacity(int capacity) {
        this.array = (K[]) new Object[capacity + 1];
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @ConstantTime
    public K findMin() {
// Path: src/main/java/org/jheaps/Constants.java
// public class Constants {
// 
//     /**
//      * Library name
//      */
//     public static final String NAME = "JHeaps";
// 
//     /**
//      * Global debug flag which affects compiled code
//      */
//     public static final boolean DEBUG = false;
// 
//     /**
//      * Global level one debug flag which affects compiled code.
//      */
//     public static final boolean DEBUG_LEVEL1 = false;
// 
//     /**
//      * Global level two debug flag which affects compiled code
//      */
//     public static final boolean DEBUG_LEVEL2 = false;
// 
//     /**
//      * Global benchmarking flag. This flag enables sanity checks when the code
//      * is not for benchmarking performance. When benchmarking we assume that the
//      * user provided the correct input.
//      */
//     public static final boolean NOT_BENCHMARK = true;
// 
//     private Constants() {
//     }
// 
// }


// Path: src/main/java/org/jheaps/array/AbstractArrayHeap.java
import java.util.Comparator;
import java.util.NoSuchElementException;
import org.jheaps.Constants;
import org.jheaps.annotations.ConstantTime;
import org.jheaps.annotations.LogarithmicTime;

/*
 * (C) Copyright 2014-2016, by Dimitrios Michail
 *
 * JHeaps Library
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jheaps.array;



/**
 * Abstract implementation of a heap using an array representation.
 * 
 * @author Dimitrios Michail
 *
 * @param <K>
 *            the type of keys maintained by this heap
 */
abstract class AbstractArrayHeap<K> extends AbstractArrayWeakHeap<K> {

    private static final long serialVersionUID = 1L;

    /**
     * Construct a new heap
     * 
     * @param comparator
     *            the comparator to use
     * @param capacity
     *            the initial capacity
     */
    public AbstractArrayHeap(Comparator<? super K> comparator, int capacity) {
        super(comparator, capacity);
    }

    /**
     * Initialize the array representation
     */
    @Override
    @SuppressWarnings("unchecked")
    protected void initCapacity(int capacity) {
        this.array = (K[]) new Object[capacity + 1];
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @ConstantTime
    public K findMin() {
        if (Constants.NOT_BENCHMARK && size == 0) {