问题描述
在Objective-C Cocoa中,我们有 NSIndexSet
类,通过保存范围数组来有效地存储一系列唯一索引。例如。集合1,2,... 30,57将被存储为范围1-30和57,而不是32个数字的数组。这有助于以简单和快速的方式存储巨大的选择。例如,如果表中的所有行都在1到1百万之间,则索引集会折叠到一个很小的范围,并且很快与之比较和相交。
不幸的是这对Google来说很难。是否有一个类的Java?
这似乎是一个有用的类,我不记得标准的实现。 / p>
这里有一些很有用的指针。
In Objective-C Cocoa we have the NSIndexSet
class which stores a series of unique indexes efficiently by keeping an array of ranges. E.g. the set 1, 2, ... 30, 57 would be stored as the ranges 1-30 and 57 rather than an array of 32 numbers. This facilitates huge selections to be stored in a simple and fast way. For example, if all rows between 1 and a million in a table selected, the index set collapses to just a tiny range and is fast to compare and intersect with.
Unfortunately this turns out to be rather hard to Google for. Is there an equivalent class for Java?
It seems a useful class, and I don't recall a standard implementation.
Here's a bunch of some -perhaps useful- pointers.
A range intersection algorithm better than O(n)?
http://www.codeproject.com/KB/recipes/rangeset.aspx
http://pcj.sourceforge.net/docs/api/bak/pcj/set/IntRangeSet.html
Data structure to build and lookup set of integer ranges
Representing sparse integer sets?
http://www.iis.uni-stuttgart.de/intset/doc/intset/TreeIntegerSet.html
这篇关于Java有IndexSet和Range类吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!