Partition selection in c++ for speedup