Class IntervalIterators
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.IntervalIterators
-
public class IntervalIterators extends Object
A class providing static methods and objects that do useful things with interval iterators.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
IntervalIterators.FakeIterator
-
Field Summary
Fields Modifier and Type Field Description static IntervalIterator
FALSE
A singleton empty interval iterator.static IntervalIterator
TRUE
A singleton iterator representing maximum truth.
-
Method Summary
Modifier and Type Method Description static ObjectSet<Interval>
pour(IntervalIterator intervalIterator)
Returns a set containing the intervals enumerated by the specified interval iterators: iteration on the set is guarantee to return the intervals in the same order in which they were enumerated.
-
-
-
Field Detail
-
TRUE
public static final IntervalIterator TRUE
A singleton iterator representing maximum truth.This iterator is a placeholder for an iterator returning just
Intervals.EMPTY_INTERVAL
. The antichain formed by the empty interval is the top element of the lattice of antichains, and thus represents the highest truth. Since, however,EMPTY_INTERVAL
is a singleton that slightly violates theInterval
invariants, an iterator actually returningEMPTY_INTERVAL
would cause severe problems in all algorithms manipulating intervals. Rather,TRUE
is treated separately and is never actually used in an algorithm on interval antichains (also because, albeit it claims to have elements, it will returnnull
onIntervalIterator.nextInterval()
).A most natural appearance of
TRUE
is due to negation: all documents satisfying a negative query returnTRUE
as interval iterator, as the query is true, but you don't know where.Warning: Before 4.0, an
IndexIterator
by convention would have returnedTRUE
whenDocumentIterator.intervalIterator(it.unimi.di.big.mg4j.index.Index)
was called with an argument that was not the key index. Now it returnsFALSE
.
-
FALSE
public static final IntervalIterator FALSE
A singleton empty interval iterator.The main usefulness of this iterator is as a singleton: in some circumstances you have to return an empty iterator, and since it is by definition stateless, it is a pity to create a new object (the same considerations led to
Collections.emptySet()
).This iterator is used by document iterators as a placeholder whenever
DocumentIterator.intervalIterator(it.unimi.di.big.mg4j.index.Index)
is called on an index for which there are not intervals. For instance, anIndexIterator
by convention returnsFALSE
whenDocumentIterator.intervalIterator(it.unimi.di.big.mg4j.index.Index)
is called with an argument that is not the key index. Before 4.0, the same placeholder role was held byTRUE
instead.
-
-
Method Detail
-
pour
public static ObjectSet<Interval> pour(IntervalIterator intervalIterator) throws IOException
Returns a set containing the intervals enumerated by the specified interval iterators: iteration on the set is guarantee to return the intervals in the same order in which they were enumerated.- Parameters:
intervalIterator
- an interval iterator.- Returns:
- a set containing the intervals enumerated by
intervalIterator
. - Throws:
IOException
-
-