Is there an IndexSet and Range class for Java?

In Cocoa's Objective-C, we have the NSIndexSet class, which effectively stores a number of unique indices, while maintaining an array of ranges. For example. set 1, 2, ... 30, 57 will be stored as ranges 1-30 and 57, and not an array of 32 numbers. This makes it easy to store huge samples in a quick and easy way. For example, if all rows are between 1 and one million in the selected table, the set of indices collapses to just a small range and quickly compares and intersects with.

Unfortunately, for Google this is quite complicated. Is there an equivalent class for Java?

+6
java indexing cocoa range
source share
3 answers

The class seems to be useful, and I don't remember the standard implementation.

Here are a bunch of some - possibly useful pointers.

Is a range crossing algorithm better than O (n)?

http://www.codeproject.com/KB/recipes/rangeset.aspx

http://healpix-rangeset.googlecode.com/svn/trunk/healpix-rangeset/src/org/asterope/healpix/LongRangeSet.java

http://pcj.sourceforge.net/docs/api/bak/pcj/set/IntRangeSet.html

Data structure for constructing and searching for a set of integer ranges

Representation of sparse whole sets?

http://www.iis.uni-stuttgart.de/intset/doc/intset/TreeIntegerSet.html

+1
source share

Apache IntRange is publicly available

+3
source share

Of course, not the last and equally important: in the Guava library there is a class Range class . This article provides a good illustration of how you can use it.

0
source share

All Articles