范围/线段树 Ruby
我正在寻找 Ruby 中的范围或段树实现。我找不到任何可用的样品或宝石。
有人有示例代码吗?
谢谢,
I am looking for a range or segment tree implementation in Ruby. I could not find any sample or gem available.
Does anyone have a sample code ?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个 Github 存储库 是...嗯...第四次在 Google 上针对“Ruby Interval Tree”进行攻击。
This Github repo is...um...the fourth hit down on Google for 'ruby interval tree'.
看起来有一个叫做
interval-tree
,repo 在这里,https:// github.com/gam3/interval-tree 和这里 https://github.com/misshie/区间树。看起来似乎是后者制造了这个东西,但红宝石上的宝石指向了前者。很奇怪。存储库和其他地方的文档都是错误的。要使用它,请使用
IntervalTree::InclusiveTree.new
或IntervalTree::ExclusiveTree.new
。这在任何地方都没有记录,这很奇怪。另外,同样奇怪的是,不可能向 github 存储库添加问题来解决此问题。我正在考虑分叉并制作一个可以由社区维护的新版本。不管怎样,这是你如何使用它的:
正如你所看到的,require 语句在存储库中也被错误地记录。真是一团糟。
There looks to be one called
interval-tree
, repo is here, https://github.com/gam3/interval-tree and here https://github.com/misshie/interval-tree. It seems like it is the later who made the thing, but the gem on rubygems points to the first. Very strange.The documentation is wrong on the repo and everywhere else. To use it, use either
IntervalTree::InclusiveTree.new
orIntervalTree::ExclusiveTree.new
. This is not documented anywhere which is strange. Also, equally strange, it is not possible to add issues to the github repo to fix this. I am considering forking and making a new version which can be maintained by the community.Anyways, here is how you use it:
As you see, also the require statement is wrongly documented in the repo. What a mess.