I would like to write a function called translate that moves a sequence in 2d array. This is based off of tsp simulated annealing. I am fairly new to c++ so my code may be terrible.
double A[][2] = { {0,0}, {1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7} };
^dst A B C
* call translate( A, 8, 5, 3, 1 ):
* after: { {0,0}, {5,5}, {6,6}, {7,7}, {1,1}, {2,2}, {3,3}, {4,4} };
* A B C
* @param A is the list of locations (x,y) of the cities in the current tour.
* @param n is the number of cities in A.
* @param src is the index of the beginning of the section to be translated (moved).
* @param len is the length of the segment to translate.
* @param dst is the index of the beginning of the target of moving.
*/
void translate ( double A[][2], int n, int src, int len, int dst ) {
}
What I have tried:
I have tried to use a queue
void translate(double A[][2], int city, int source, int length, int destination) {
double *pointer;
queue<int> city;
for (int i = src; i < src + len; src++) {
q.push(i);
while (len < n) {
q.push(i);
}
}