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
boutta
  • 24,189
  • 7
  • 34
  • 49

4 Answers4

3

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.

Eyal
  • 3,412
  • 1
  • 44
  • 60
Gadi
  • 472
  • 4
  • 10
  • I've seen the ranges, but since they are type specific they are not so useful as the classes from the Time&Money library. – boutta Apr 07 '09 at 13:37
  • 1
    The [Apache 3 version of Range](http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/Range.html) uses generics. – Eyal Jul 19 '15 at 14:40
1

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

tpdi
  • 34,554
  • 11
  • 80
  • 120
1

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

See these files in their svn: interval package.

Sergey
  • 2,906
  • 3
  • 27
  • 32
0

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

Alain P
  • 1,293
  • 8
  • 16