private int bubbleDown(int index, double x) {
		while (index * 3 <= size) {
			int target;
			int left = index * 3 - 1;
			int middle = index * 3;
			int right = index * 3 + 1;
			if (middle > size) {
				target = left;
			} else if (right > size) {
				if (heapArray[left] < heapArray[middle]) {
					target = left;
				} else {
					target = middle;
				}
			} else {
				if (heapArray[left] <= heapArray[middle] && heapArray[left] <= heapArray[right]) {
					target = left;
				} else if (heapArray[middle] <= heapArray[left] && heapArray[middle] <= heapArray[right]) {
					target = middle;
				} else {
					target = right;
				}
			}
			if (heapArray[target] < x) {
				heapArray[index] = heapArray[target];
				index = target;
			} else {
				break;
			}
		}
		return index;
	}