// Path: src/main/java/org/jheaps/Heap.java
// public interface Heap<K> {
// 
//     /**
//      * Returns the comparator used to order the keys in this heap, or
//      * {@code null} if this heap uses the {@linkplain Comparable natural
//      * ordering} of its keys.
//      *
//      * @return the comparator used to order the keys in this heap, or
//      *         {@code null} if this heap uses the natural ordering of its keys
//      */
//     Comparator<? super K> comparator();
// 
//     /**
//      * Insert a key into the heap.
//      *
//      * @param key
//      *            the key to insert
//      */
//     void insert(K key);
// 
//     /**
//      * Find an element with the minimum key.
//      *
//      * @return an element with the minimum key
//      * @throws NoSuchElementException
//      *             if the heap is empty
//      */
//     K findMin();
// 
//     /**
//      * Delete and return an element with the minimum key. If multiple such
//      * elements exists, only one of them will be deleted.
//      *
//      * @return the deleted element with the minimum key
//      * @throws NoSuchElementException
//      *             if the heap is empty
//      */
//     K deleteMin();
// 
//     /**
//      * Returns {@code true} if this heap is empty.
//      *
//      * @return {@code true} if this heap is empty, {@code false} otherwise
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns the number of elements in this heap.
//      *
//      * @return the number of elements in this heap
//      */
//     long size();
// 
//     /**
//      * Clear all the elements of this heap.
//      */
//     void clear();
// 
// }
// 
// Path: src/main/java/org/jheaps/monotone/IntegerRadixHeap.java
// public class IntegerRadixHeap extends AbstractRadixHeap<Integer> {
// 
//     private static final long serialVersionUID = 1;
// 
//     /**
//      * Constructs a new heap which can store values between a minimum and a
//      * maximum key value (inclusive).
//      * 
//      * It is important to use the smallest key range as the heap uses O(logC)
//      * where C=maxKey-minKey+1 buckets to store elements. Moreover, the
//      * operation {@code deleteMin} requires amortized O(logC) time.
//      * 
//      * @param minKey
//      *            the non-negative minimum key that this heap supports
//      *            (inclusive)
//      * @param maxKey
//      *            the maximum key that this heap supports (inclusive)
//      * @throws IllegalArgumentException
//      *             if the minimum key is negative
//      * @throws IllegalArgumentException
//      *             if the maximum key is less than the minimum key
//      */
//     @SuppressWarnings("unchecked")
//     public IntegerRadixHeap(int minKey, int maxKey) {
//         super();
//         if (minKey < 0) {
//             throw new IllegalArgumentException("Minimum key must be non-negative");
//         }
//         this.minKey = minKey;
//         this.lastDeletedKey = minKey;        
//         if (maxKey < minKey) {
//             throw new IllegalArgumentException("Maximum key cannot be less than the minimum");
//         }
//         this.maxKey = maxKey;
// 
//         // compute number of buckets
//         int numBuckets;
//         if (maxKey == minKey) {
//             numBuckets = 2;
//         } else {
//             numBuckets = 2 + 1 + (int) Math.floor(Math.log((double)maxKey - minKey) / Math.log(2));
//         }
// 
//         // construct representation
//         this.buckets = (List<Integer>[]) Array.newInstance(List.class, numBuckets);
//         for (int i = 0; i < this.buckets.length; i++) {
//             buckets[i] = new ArrayList<Integer>();
//         }
//         this.size = 0;
//         this.currentMin = null;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     protected int compare(Integer o1, Integer o2) {
//         if (o1 < o2) {
//             return -1;
//         } else if (o1 > o2) {
//             return 1;
//         } else {
//             return 0;
//         }
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     protected int msd(Integer a, Integer b) {
//         /*
//          * Value equal
//          */
//         if (a.intValue() == b.intValue()) {
//             return -1;
//         }
//         /*
//          * This is a fast way to compute floor(log_2(a xor b)).
//          */
//         float axorb = a ^ b;
//         return Math.getExponent(axorb);
//     }
// 
// }


import org.jheaps.Heap;
import org.jheaps.monotone.IntegerRadixHeap;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;
/*
 * (C) Copyright 2014-2018, 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.monotone;




public class IntegerRadixHeapTest {

	private static final int SIZE = 100000;

    @Test
    public void testBug2() {
// Path: src/main/java/org/jheaps/Heap.java
// public interface Heap<K> {
// 
//     /**
//      * Returns the comparator used to order the keys in this heap, or
//      * {@code null} if this heap uses the {@linkplain Comparable natural
//      * ordering} of its keys.
//      *
//      * @return the comparator used to order the keys in this heap, or
//      *         {@code null} if this heap uses the natural ordering of its keys
//      */
//     Comparator<? super K> comparator();
// 
//     /**
//      * Insert a key into the heap.
//      *
//      * @param key
//      *            the key to insert
//      */
//     void insert(K key);
// 
//     /**
//      * Find an element with the minimum key.
//      *
//      * @return an element with the minimum key
//      * @throws NoSuchElementException
//      *             if the heap is empty
//      */
//     K findMin();
// 
//     /**
//      * Delete and return an element with the minimum key. If multiple such
//      * elements exists, only one of them will be deleted.
//      *
//      * @return the deleted element with the minimum key
//      * @throws NoSuchElementException
//      *             if the heap is empty
//      */
//     K deleteMin();
// 
//     /**
//      * Returns {@code true} if this heap is empty.
//      *
//      * @return {@code true} if this heap is empty, {@code false} otherwise
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns the number of elements in this heap.
//      *
//      * @return the number of elements in this heap
//      */
//     long size();
// 
//     /**
//      * Clear all the elements of this heap.
//      */
//     void clear();
// 
// }
// 
// Path: src/main/java/org/jheaps/monotone/IntegerRadixHeap.java
// public class IntegerRadixHeap extends AbstractRadixHeap<Integer> {
// 
//     private static final long serialVersionUID = 1;
// 
//     /**
//      * Constructs a new heap which can store values between a minimum and a
//      * maximum key value (inclusive).
//      * 
//      * It is important to use the smallest key range as the heap uses O(logC)
//      * where C=maxKey-minKey+1 buckets to store elements. Moreover, the
//      * operation {@code deleteMin} requires amortized O(logC) time.
//      * 
//      * @param minKey
//      *            the non-negative minimum key that this heap supports
//      *            (inclusive)
//      * @param maxKey
//      *            the maximum key that this heap supports (inclusive)
//      * @throws IllegalArgumentException
//      *             if the minimum key is negative
//      * @throws IllegalArgumentException
//      *             if the maximum key is less than the minimum key
//      */
//     @SuppressWarnings("unchecked")
//     public IntegerRadixHeap(int minKey, int maxKey) {
//         super();
//         if (minKey < 0) {
//             throw new IllegalArgumentException("Minimum key must be non-negative");
//         }
//         this.minKey = minKey;
//         this.lastDeletedKey = minKey;        
//         if (maxKey < minKey) {
//             throw new IllegalArgumentException("Maximum key cannot be less than the minimum");
//         }
//         this.maxKey = maxKey;
// 
//         // compute number of buckets
//         int numBuckets;
//         if (maxKey == minKey) {
//             numBuckets = 2;
//         } else {
//             numBuckets = 2 + 1 + (int) Math.floor(Math.log((double)maxKey - minKey) / Math.log(2));
//         }
// 
//         // construct representation
//         this.buckets = (List<Integer>[]) Array.newInstance(List.class, numBuckets);
//         for (int i = 0; i < this.buckets.length; i++) {
//             buckets[i] = new ArrayList<Integer>();
//         }
//         this.size = 0;
//         this.currentMin = null;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     protected int compare(Integer o1, Integer o2) {
//         if (o1 < o2) {
//             return -1;
//         } else if (o1 > o2) {
//             return 1;
//         } else {
//             return 0;
//         }
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     protected int msd(Integer a, Integer b) {
//         /*
//          * Value equal
//          */
//         if (a.intValue() == b.intValue()) {
//             return -1;
//         }
//         /*
//          * This is a fast way to compute floor(log_2(a xor b)).
//          */
//         float axorb = a ^ b;
//         return Math.getExponent(axorb);
//     }
// 
// }


// Path: src/test/java/org/jheaps/monotone/IntegerRadixHeapTest.java
import org.jheaps.Heap;
import org.jheaps.monotone.IntegerRadixHeap;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

/*
 * (C) Copyright 2014-2018, 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.monotone;




public class IntegerRadixHeapTest {

	private static final int SIZE = 100000;

    @Test
    public void testBug2() {
        Heap<Integer> h = new IntegerRadixHeap(0, 100);