I'm working on a Java generic implementation of AVL trees (the source code is at https://github.com/diningphil/AvlTreeJava), and I've came across a specific problem: if I pass the insert method an argument T key, and then modify the fields of key after insertion, the data structure is corrupted.
How can I avoid this? Can I pass an object requiring that it is not modifiable afterwards by the user but by the implementation of my avl trees?
Thanks in advance