IntervalTree DeleteNode Java实现 [英] IntervalTree DeleteNode Java Implementation

查看:90
本文介绍了IntervalTree DeleteNode Java实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个 IntervalTree 或Java中的RangeTree实现,并且很难找到一个工作删除支持.

I need an IntervalTree or RangeTree implementation in Java, and am having trouble finding one with working deletion support.

sun.jvm.hotspot.utilities.IntervalTree ,但尝试从树中删除节点最终会引发异常:

Trying to delete nodes from a tree ends up throwing the exception:

节点的最大端点未更新 正确

Node's max endpoint was not updated properly

在sun.jvm.hotspot.utilities.IntervalTree的子类中正确实现delete功能有多困难?还是有另一个Interval Tree实现已经正确实现了?

How difficult would it be to properly implement delete functionality in a subclass of the sun.jvm.hotspot.utilities.IntervalTree? Or is there another Interval Tree implementation which already implements this correctly?

当前,我只是清除树并在每次删除时重新填充它,这远非理想(请注意:在RBTree中将DEBUGGING = false设置为极大地加快了速度).

Currently I'm just wiping out the tree and re-populating it every time there's a deletion, which is far from ideal (note: setting DEBUGGING=false in the RBTree sped things up tremendously).

推荐答案

我最终修改了sun.jvm.hotspot.utilities.IntervalTree,以维护一组已删除的节点.进行搜索时,我会排除此集合中的所有项目.这并不理想,但是这比使真正的"删除工作容易得多.一旦删除的集变得太大,我就会重建树.

I ended up modifying the sun.jvm.hotspot.utilities.IntervalTree to maintain a Set of deleted nodes. When doing a search, I exclude any items in this set. Not ideal, but this was a lot easier than getting "real" deletion working. Once the deleted set gets too large, I rebuild the tree.

这篇关于IntervalTree DeleteNode Java实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆