|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.webgraph.MaskedIntIterator
public class MaskedIntIterator
An iterator returning the element of an underlying iterator but filters them using a inclusion-exclusion block list.
A mask is an array of integers. The sum of the values contained in the mask must not exceed the number of elements returned by the underlying iterator. Moreover, all integers in the mask must be positive, except possibly for the first one, which may be zero.
Mask values are interpreted as specifying inclusion-exclusion blocks. Suppose that the underlying iterator returns N values, and that the mask is n0, n1, …, nk. Then, the first n0 values returned by the underlying iterator must be kept, the next n1 values must be ignored, the next n2 must be kept and so on. The last N−(n0+…+nk) must be kept if k is odd, and must be ignored otherwise. An instance of this class will returns the kept values only, in increasing order.
Constructor Summary | |
---|---|
MaskedIntIterator(int[] mask,
int maskLen,
LazyIntIterator underlying)
Creates a new masked iterator using a given mask, mask length and underlying iterator. |
|
MaskedIntIterator(int[] mask,
LazyIntIterator underlying)
Creates a new masked iterator using a given mask and underlying iterator. |
Method Summary | |
---|---|
int |
nextInt()
The next integer returned by this iterator, or the special marker if this iterator is exhausted. |
int |
skip(int n)
Skips a given number of elements. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MaskedIntIterator(int[] mask, LazyIntIterator underlying)
mask
- a mask, or null
, meaning an empty mask (everything is copied).underlying
- an underlying iterator.public MaskedIntIterator(int[] mask, int maskLen, LazyIntIterator underlying)
mask
- a mask, or null
, meaning an empty mask (everything is copied).maskLen
- an explicit mask length.underlying
- an underlying iterator.Method Detail |
---|
public int nextInt()
LazyIntIterator
nextInt
in interface LazyIntIterator
public int skip(int n)
LazyIntIterator
skip
in interface LazyIntIterator
n
- the number of elements to skip.
n
if this iterator is exhausted).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |