Java 是否存在开放式区间实现?

发布于 2024-07-16 17:35:22 字数 161 浏览 4 评论 0原文

我对不同区间的某些值进行了分类。 大多数具有 [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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

相思碎 2024-07-23 17:35:23

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.

箹锭⒈辈孓 2024-07-23 17:35:23

Time&Money 项目似乎有您需要的 Interval 类。

在它们的 svn 中查看这些文件: 间隔套餐

Time&Money project seems to have Interval class that you need.

See these files in their svn: interval package.

述情 2024-07-23 17:35:23

我知道没有图书馆课程,但我记得编写此类课程相当简单。

I know of no library classes, but I recall rather trivially writing such classes.

始终不够 2024-07-23 17:35:23

对于那些最终可能会来到这里的人,您可以查看 Google Ranges,其中包括正是这里所问的。

For those who might end up here, you can have a look at Google Ranges which are exactly what was asked here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文