英文:
Is it possible to change only one method of a data structure that is already built in for java?
问题
我目前有一个从Java导入的二叉搜索树,已经建好了。我是否可以在不必从头开始重新创建整个数据结构的情况下更改添加/插入方法?我希望在遍历的每个步骤中都进行额外的检查。
英文:
I currently have a binary search tree imported from java which is already built in. Is it possible for me to change the add/insert method without having to recreate the entire data structure from scratch? I want to do an extra check during each step of the traversal.
答案1
得分: 0
通常在这种情况下,您可能会考虑应用"访问者模式"。
英文:
Generally in cases like this you might want to consider applying "visitor pattern"
专注分享java语言的经验与见解,让所有开发者获益!
评论