IntervalTree DeleteNode Java Implementation

前端 未结 5 1325
無奈伤痛
無奈伤痛 2021-02-06 08:14

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

There\'s a built-in one at sun.jvm.hotspot.u

5条回答
  •  青春惊慌失措
    2021-02-06 08:44

    I found an open-source implementation with deletion, but it neeeds some effort to make it fully functional.

    It's a module of larger open-source project Gephi, but here are the sources and javadoc. If you want a jar you can install the Gephi, and it's in:

    /gephi/modules/org-gephi-data-attributes-api.jar
    

    The delete method there, removes all intervals overlapping with the input interval (instead of just the input one). However I found in the soruces that there are private methods that remove a specific node (which stores one interval). Also the private search methods return nodes.

    So I think with some little effort it's possible to refactor the code and have this - 'delete specific interval' feature. The fastest and most dirty way would be to just make the private methods/Node class public. But since it's an open source project, maybe it could evolve in future into some good standard implementation of interval tree.

提交回复
热议问题