0

Hello!

I am trying to implement a persistent data structure using a vector of linked lists, but each time I am adding the modified list to the vector, all the old entries seem to be updated... Could you please help me?

Definition of the vector of linked lists (the list is defined as RBTree):

```
vector<RBTree*> persistentList;
// Create a copy of the list
RBTree myRBTreeCopy = *myRBTree;
// Store the list in the vector persistentList in the "noCopies-1"th position
persistentList.push_back(&myRBTreeCopy);
// Increment number of persistent data structures
noCopies++;
```

To illustrate what I mean, when I output:

```
persistentList[0]->print(persistentList[0]->root);
```

and expect to see an empty linked list, I obtain the final list after I have inserted all the elements.

Thank you in advance for your help and please let me know if any clarification is needed.