Java 是否存在开放式区间实现?
我对不同区间的某些值进行了分类。 大多数具有 [20-30] 的形式,但有些具有 [30-无限) 的形式。
您是否知道有一个区间类可以表示:
- 两边都不闭合的区间(例如 (0-5) 或 [0-5) )
- 无限闭合(或开始)的区间
I've got a classification of certain values in different intervals. Most have the form [20-30], but some are of the form [30-infinite).
Is there an interval class you know of which can represent:
- an interval which is not closed on both sides (e.g. (0-5) or [0-5) )
- an interval which closes (or starts) on infinite
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Apache-commons-lang 项目 (http://commons.apache.org/lang/)包含处理范围的类(例如 IntRange - https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/math/IntRange.html)。 我不确定它能满足您的所有需求,但可能值得检查。
The Apache-commons-lang project (http://commons.apache.org/lang/) contains classes dealing with ranges (like IntRange - https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/math/IntRange.html). I'm not sure it covers all your needs, but it might be worth checking.
Time&Money 项目似乎有您需要的 Interval 类。
在它们的 svn 中查看这些文件: 间隔套餐。
Time&Money project seems to have Interval class that you need.
See these files in their svn: interval package.
我知道没有图书馆课程,但我记得编写此类课程相当简单。
I know of no library classes, but I recall rather trivially writing such classes.
对于那些最终可能会来到这里的人,您可以查看 Google Ranges,其中包括正是这里所问的。
For those who might end up here, you can have a look at Google Ranges which are exactly what was asked here.