java.lang.Object
org.bitlap.roaringbitmap.IntIteratorFlyweight
- 所有已实现的接口:
Cloneable,IntIterator,PeekableIntIterator
Fast iterator minimizing the stress on the garbage collector. You can create one reusable
instance of this class and then
wrap(RoaringBitmap)
For better performance, consider the RoaringBitmap.forEach(org.bitlap.roaringbitmap.IntConsumer) method.-
构造器概要
构造器构造器说明Creates an instance that is not ready for iteration.Creates an instance that is ready for iteration. -
方法概要
修饰符和类型方法说明voidadvanceIfNeeded(int minval) If needed, advance as long as the next value is smaller than minval The advanceIfNeeded method is used for performance reasons, to skip over unnecessary repeated calls to next.clone()Creates a copy of the iterator.booleanhasNext()intnext()intpeekNext()Look at the next value without advancing The peek is useful when working with several iterators at once.voidPrepares a bitmap for iteration
-
构造器详细资料
-
IntIteratorFlyweight
public IntIteratorFlyweight()Creates an instance that is not ready for iteration. You must first callwrap(RoaringBitmap). -
IntIteratorFlyweight
Creates an instance that is ready for iteration.- 参数:
r- bitmap to be iterated over
-
-
方法详细资料
-
clone
从接口复制的说明:PeekableIntIteratorCreates a copy of the iterator.- 指定者:
clone在接口中IntIterator- 指定者:
clone在接口中PeekableIntIterator- 覆盖:
clone在类中Object- 返回:
- a clone of the current iterator
-
hasNext
public boolean hasNext()- 指定者:
hasNext在接口中IntIterator- 返回:
- whether there is another value
-
next
public int next()- 指定者:
next在接口中IntIterator- 返回:
- next integer value
-
wrap
Prepares a bitmap for iteration- 参数:
r- bitmap to be iterated over
-
advanceIfNeeded
public void advanceIfNeeded(int minval) 从接口复制的说明:PeekableIntIteratorIf needed, advance as long as the next value is smaller than minval The advanceIfNeeded method is used for performance reasons, to skip over unnecessary repeated calls to next. Suppose for example that you wish to compute the intersection between an ordered list of integers (e.g., int[] x = {1,4,5}) and a PeekableIntIterator. You might do it as follows...
The benefit of calling advanceIfNeeded is that each such call can be much faster than repeated calls to "next". The underlying implementation can "skip" over some data.PeekableIntIterator j = // get an iterator int val = // first value from my other data structure j.advanceIfNeeded(val); while ( j.hasNext() ) { if(j.next() == val) { // ah! ah! val is in the intersection... // do something here val = // get next value? } j.advanceIfNeeded(val); }- 指定者:
advanceIfNeeded在接口中PeekableIntIterator- 参数:
minval- threshold
-
peekNext
public int peekNext()从接口复制的说明:PeekableIntIteratorLook at the next value without advancing The peek is useful when working with several iterators at once. Suppose that you have 100 iterators, and you want to compute their intersections without materializing the result. You might do it as follows...
Notice how the peek method allows you to compare iterators in a way that the next method could not do.PriorityQueue pq = new PriorityQueue(100, new Comparator<PeekableIntIterator>() { public int compare(PeekableIntIterator a, PeekableIntIterator b) { return a.peek() - b.peek(); } }); //... populate pq while(! pq.isEmpty() ) { // get iterator with a smallest value PeekableIntIterator pi = pq.poll(); int x = pi.next(); // advance // do something with x if(pi.hasNext()) pq.add(pi) }- 指定者:
peekNext在接口中PeekableIntIterator- 返回:
- next value
-