可以更改已在Java中构建的数据结构的一个方法吗?

huangapple 未分类评论44阅读模式
英文:

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"

huangapple
  • 本文由 发表于 2020年4月9日 10:45:45
  • 转载请务必保留本文链接:https://java.coder-hub.com/61113155.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定