private void reheapify() {
		E root = array.get(1);

		int lastIndex = array.size() - 1;

		int index = 1;
		boolean more = true;
		while (more) {
			int childIndex = getLeftChildIndex(index);
			if (childIndex <= lastIndex) {
				E child = getLeftChild(index);

				// Use right child instead if it is smaller.
				if (getRightChildIndex(index) <= lastIndex
						&& comp.compare(getRightChild(index), child) < 0) {
					childIndex = getRightChildIndex(index);
					child = getRightChild(index);
				}

				// Check if larger child is smaller than root.
				if (comp.compare(child, root) < 0) {
					array.set(index, child);
					index = childIndex;
				} else
					more = false;
			} else
				more = false;
		}

		// Store root element.
		array.set(index, root);
	}