I have some like so:
struct Node{
int value;
Node *left, Node *right;
Node(): value(0), left(0), right(0){}
}
std::vector<Node> nodeList = getNodes();
I want the above to make a circular buffer. So
nodeList[i].left = &nodeList[i - 1];
nodeList[i].right= &nodeList[i + 1];
note that nodeList[0].left points to the end of the nodeList and nodeList.back().right points to the beginning on the nodeList;
Now here is the problem, nodeList[i].left and nodeList[i].right only points to the address of its previous neighbor, but does not necessarily point to the actual neighbor object. So if I were to sort the nodeList, the left and right pointer won't point to the original node anymore. Instead they will point to the new left and right neighbor. Hope the problem is clear, how can I have it so that for example nodeList[1].left points to nodeList[0] even if nodeList[0] got moved to a different spot?