<commit_before>package it.rz.algoritmi.binaryHeap;

import java.lang.reflect.Array;

public class BinaryMinHeap<V> {
	
	/*
	 * Number of nodes is N = sum(2^l) for l from 0 to the number of levels-1.
	 * E.g. for 4 levels => N = 2^0 + 2^1 + 2^2 + 2^3 = 1 + 2 + 4 + 8 = 15 
	 * Is that N = 2^l -1     ===>    l = log2(N+1) 
	 */
	protected static final int NUMERO_LIVELLI_INIZIALI = 4;
	protected static final int NUMERO_NODI_INIZIALI = (2^NUMERO_LIVELLI_INIZIALI)-1;
	
	private final V[] data;
	private int heapNumberOfNodes = 0;

	@SuppressWarnings("unchecked")
	public BinaryMinHeap(Class<V> clazz) {
		this.data = (V[]) Array.newInstance(clazz, NUMERO_NODI_INIZIALI);
	}


	public int getLeftIndex(int currentIndex) {
		if (currentIndex < 0 ) {
			throw new BinaryMinHeapException("The currentIndex can not be negative. Passed index was:" + currentIndex); 
		}
		return (2 * currentIndex) + 1;
	}

	public int getRightIndex(int currentIndex) {
		if (currentIndex < 0 ) {
			throw new BinaryMinHeapException("The currentIndex can not be negative. Passed index was:" + currentIndex); 
		}
		return (2 * currentIndex) + 2;
	}

	public int getParentIndex(int currentIndex) {
		if (currentIndex <= 0 ) {
			throw new BinaryMinHeapException("The currentIndex can not be zero or negative. Passed index was:" + currentIndex); 
		}
		return (currentIndex -1) / 2;
	}

	public boolean isEmpty() {
		return (this.heapNumberOfNodes == 0);
	}
	
}<commit_msg>Implemented getMinimum() for the case of empty heap only, just to pass the test. Added the constraint of the generic type V implementing Comparable as we will need to order them.<commit_after>package it.rz.algoritmi.binaryHeap;

import java.lang.reflect.Array;

public class BinaryMinHeap<V extends Comparable<V>> {
	
	/*
	 * Number of nodes is N = sum(2^l) for l from 0 to the number of levels-1.
	 * E.g. for 4 levels => N = 2^0 + 2^1 + 2^2 + 2^3 = 1 + 2 + 4 + 8 = 15 
	 * Is that N = 2^l -1     ===>    l = log2(N+1) 
	 */
	protected static final int NUMERO_LIVELLI_INIZIALI = 4;
	protected static final int NUMERO_NODI_INIZIALI = (2^NUMERO_LIVELLI_INIZIALI)-1;
	
	private final V[] data;
	private int numberOfNodes = 0;

	@SuppressWarnings("unchecked")
	public BinaryMinHeap(Class<V> clazz) {
		this.data = (V[]) Array.newInstance(clazz, NUMERO_NODI_INIZIALI);
	}

	protected int getLeftIndex(int currentIndex) {
		if (currentIndex < 0 ) {
			throw new BinaryMinHeapException("The currentIndex can not be negative. Passed index was:" + currentIndex); 
		}
		return (2 * currentIndex) + 1;
	}

	protected int getRightIndex(int currentIndex) {
		if (currentIndex < 0 ) {
			throw new BinaryMinHeapException("The currentIndex can not be negative. Passed index was:" + currentIndex); 
		}
		return (2 * currentIndex) + 2;
	}

	protected int getParentIndex(int currentIndex) {
		if (currentIndex <= 0 ) {
			throw new BinaryMinHeapException("The currentIndex can not be zero or negative. Passed index was:" + currentIndex); 
		}
		return (currentIndex -1) / 2;
	}

	public boolean isEmpty() {
		return (this.numberOfNodes == 0);
	}

	public V getMinimum() {
		if (isEmpty()) {
			throw new BinaryMinHeapException("There is no minimum in an Empty Heap.");
		}
		return null;
	}
	
}
{'fraction_non_alphanumeric': 0.1115933044017359, 'fraction_numerical': 0.022318660880347178, 'mean_word_length': 3.7455882352941177, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7318937', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1094, 'n_words': 345}