Exemplo n.º 1
0
int main() {

	std::vector<timeTuple> ranges;
	// ranges.emplace_back(0,1);
	// ranges.emplace_back(3,5);
	// ranges.emplace_back(4,8);
	// ranges.emplace_back(10,12);
	// ranges.emplace_back(9,10);

	// ranges.emplace_back(1,3);
	// ranges.emplace_back(2,4);

	ranges.emplace_back(1,10);
	ranges.emplace_back(2,6);
	ranges.emplace_back(3,5);
	ranges.emplace_back(7,9);

	std::vector<timeTuple> mergedRanges = mergeRanges(ranges);

	for (auto& i : mergedRanges) {
		printf("(%i, %i)\n", i.startTime, i.endTime);
	}

	return 0;
}
void mergesortRange(int values[], int startIndex, int endIndex){
  int rangeSize = endIndex - startIndex;
  if(needsSorting(rangeSize)){
    int midPoint = (startIndex + endIndex) / 2;
    mergesortRange(values, startIndex, midPoint);
    mergesortRange(values, midPoint, endIndex);
    mergeRanges(values, startIndex, midPoint, endIndex);
  }
}