I've been trying to do deep copy of a 2 dimensional array but never succeeded. Here is my code.
class node {
public node head;
public node left;
public node right;
public node up;
public node down;
}
node[][] OriginalArrayOfNode = new node[100][200];
//filling original node
for (int n = 0; n < 200; n++) {
for(int m = 0; m < 100; m++) {
OriginalArrayOfNode[m][n].head = OriginalArrayOfNode[m][0];
OriginalArrayOfNode[m][n].left = ...
//etc
}
}
node[][]CopyArrayOfNode = new node[100][200];
//The code to copy the original array to new array should be here.
My question is how can i make a deep copy of my the OriginalArrayOfNode to CopyArrayOfNode ? Thanks in advance.
EDIT :
Im trying to make a copy of circular doubly-linked list with 4 pointers for Knuth's Dancing Link Algorithm. It's pretty hard to trace where is the problem, but i assume if the original-array give "x" as a result from Knuth's DL Algorithm, then a correct deep copy of the original-array will also give "x" as a result, provided that there are no other variable change and no random modifier. However, ive tried clone() method, arrayutil.copy() method, and none of them give a "correct" deep copy based on my assumption above.