@Override public LongSortedSet headSet(final long to) { if (this == EMPTY_INTERVAL) return this; if (to > left) return to > right ? this : valueOf(left, to - 1); else return EMPTY_INTERVAL; }
@Override public LongSortedSet tailSet(final long from) { if (this == EMPTY_INTERVAL) return this; if (from <= right) return from <= left ? this : valueOf(from, right); else return EMPTY_INTERVAL; }
/** Creates a new subsequence. * * @param underlyingSequence the underlying document sequence. * @param first the first document (inclusive) in the subsequence. * @param last the last document (exclusive) in this subsequence. */ public SubsetDocumentSequence( DocumentSequence underlyingSequence, long first, long last ) { this.underlyingSequence = underlyingSequence; this.documents = last <= first? LongIntervals.EMPTY_INTERVAL : LongInterval.valueOf( first, last - 1 ); }
@Override public LongSortedSet subSet(final long from, final long to) { if (this == EMPTY_INTERVAL) return this; if (from > to) throw new IllegalArgumentException("Start element (" + from + ") is larger than end element (" + to + ")"); if (to <= left || from > right || from == to) return EMPTY_INTERVAL; if (from <= left && to > right) return this; return valueOf(Math.max(left, from), Math.min(right, to - 1)); }
path = e.path; for(i = 0; i < path.length - 1 && offset + i < l && s.charAt(offset + i) == path[i]; i++); if (offset + i == l) return LongInterval.valueOf(wordsAtLeft, wordsAtLeft + e.numNodes - 1); if (i < path.length - 1) return LongIntervals.EMPTY_INTERVAL; offset += i; offset++; if (e.left != null) wordsAtLeft += e.left.numNodes; if (offset == l) return LongInterval.valueOf(wordsAtLeft, wordsAtLeft + (e.isWord ? 1 : 0) + (e.middle == null ? 0 : e.middle.numNodes) - 1); if (e.isWord) wordsAtLeft++; e = e.middle;
if (offset + i == l) { return wordsAtLeft > 0 ? LongInterval.valueOf(wordsAtLeft - 1, wordsAtLeft + e.numNodes - 1) : LongInterval.valueOf(wordsAtLeft, wordsAtLeft + e.numNodes - 1); if (s.charAt(offset + i) < path[i]) return wordsAtLeft > 0 ? LongInterval.valueOf(wordsAtLeft -1) : LongIntervals.EMPTY_INTERVAL; else return LongInterval.valueOf(wordsAtLeft + e.numNodes - 1); offset++; if (e.left != null) wordsAtLeft += e.left.numNodes; if (offset == l) return LongInterval.valueOf(wordsAtLeft - (e.isWord ? 0 : 1), wordsAtLeft + (e.isWord ? 1 : 0) + (e.middle == null ? 0 : e.middle.numNodes) - 1); if (e.isWord) wordsAtLeft++; e = e.middle; return wordsAtLeft > 0 ? LongInterval.valueOf(wordsAtLeft - 1) : LongIntervals.EMPTY_INTERVAL;
@Override public LongInterval get(final Object key) { final Interval interval = prefixMapRangeMap.get(key); return LongInterval.valueOf(interval.left, interval.right); }
public LongInterval get( Object o ) { CharSequence prefix = (CharSequence)o; try { ensureConnection(); remoteConnection.outputStream.writeByte( RemotePrefixMap.GET_INTERVAL ); new MutableString( prefix ).writeSelfDelimUTF8( (OutputStream)remoteConnection.outputStream ); remoteConnection.outputStream.flush(); return LongInterval.valueOf( remoteConnection.inputStream.readLong(), remoteConnection.inputStream.readLong() ); } catch ( Exception e ) { throw new RuntimeException( e ); } }
/** Returns an interval with given extremes. * * <P>You cannot obtain an empty interval with this factory method. Use {@link Intervals#EMPTY_INTERVAL} instead. * * @param left the left extreme. * @param right the right extreme (which must be greater than * or equal to the left extreme). * @return an interval with the given extremes. */ public static LongInterval valueOf(final long left, final long right) { if (left > right) throw new IllegalArgumentException("The left extreme (" + left + ") is greater than the right extreme (" + right + ")"); if (left == right) return valueOf(left); return new LongInterval(left, right); }
return n.word > 0 ? LongInterval.valueOf(n.word - 1) : LongIntervals.EMPTY_INTERVAL; return LongInterval.valueOf(n.word); return LongInterval.valueOf(n.word); return LongInterval.valueOf(n.word); if (l.word == 0) return mismatch ? LongIntervals.EMPTY_INTERVAL : LongInterval.valueOf(l.word, n.word); else return LongInterval.valueOf(l.word - 1, n.word); return LongInterval.valueOf(l.word, n.word);
return n.word > 0 ? LongInterval.valueOf(n.word - 1) : LongIntervals.EMPTY_INTERVAL; return LongInterval.valueOf(n.word); return LongInterval.valueOf(n.word); return LongInterval.valueOf(n.word); if (l.word == 0) return mismatch ? LongIntervals.EMPTY_INTERVAL : LongInterval.valueOf(0); else return LongInterval.valueOf(l.word - 1, n.word); return LongInterval.valueOf(l.word, n.word);
new MutableString( prefixMap.prefixMap().get( LongInterval.valueOf( inputStream.readLong(), inputStream.readLong() ) ) ).writeSelfDelimUTF8( (OutputStream)outputStream ); outputStream.flush(); break;
return LongInterval.valueOf(l.word, n.word);
return LongInterval.valueOf(l.word, n.word);
return LongInterval.valueOf(start, end - 1); } catch (IOException rethrow) { throw new RuntimeException(rethrow);