Package it.unimi.dsi.util

Examples of it.unimi.dsi.util.Interval


   * provided their number does not exceed the given limit and that this index has a {@link #prefixMap}.
   */
 
  public IndexIterator documents( final CharSequence prefix, final int limit ) throws IOException, TooManyTermsException {
    if ( prefixMap != null ) {
      final Interval interval = prefixMap.rangeMap().get( prefix );
      if ( interval == Intervals.EMPTY_INTERVAL ) return new Index.EmptyIndexIterator();
      final IndexIterator result;
     
      if ( interval.length() > limit ) throw new TooManyTermsException( interval.length() );
     
      if ( interval.length() == 1 ) result = documents( interval.left );
      else {
        IndexIterator[] baseIterator = new IndexIterator[ interval.length()];
        int k = 0;
        for( IntIterator i = interval.iterator(); i.hasNext(); ) baseIterator[ k++ ] = documents( i.nextInt() );
     
        result = MultiTermIndexIterator.getInstance( this, baseIterator );
      }
      result.term( prefix + "*" );
      return result;
View Full Code Here


      aligneeIntervalIterator.intervalTerms( terms );
    }

    public Interval nextInterval() throws IOException {
      if ( next != null ) {
        final Interval result = next;
        next = null;
        return result;
      }

      if ( endOfProcess ) return null;
     
      Interval aligneeInterval = null, alignerInterval = null;
     
      aligneeInterval = aligneeIntervalIterator.nextInterval();
      alignerInterval = alignerIntervalIterator.nextInterval();
      if ( aligneeInterval == null || alignerInterval == null ) {
        endOfProcess = true;
        return null;
      }
     
      while ( ! aligneeInterval.equals( alignerInterval ) ) {
        if ( aligneeInterval.left <= alignerInterval.left ) {
          if ( ( aligneeInterval = aligneeIntervalIterator.nextInterval() ) == null ) {
            endOfProcess = true;
            return null;
          }
View Full Code Here

      terms.add( aligneeIndexIterator.termNumber() );
    }

    public Interval nextInterval() {
      if ( next != null ) {
        final Interval result = next;
        next = null;
        return result;
      }
     
      if ( endOfProcess ) return null;
View Full Code Here

     * @return the next interval, as cached by {@link #hasNext()}.
     */
    @Deprecated
    public Interval next() {
      if ( ! hasNext() ) throw new NoSuchElementException();
      final Interval result = next;
      next = null;
      return result;
    }
View Full Code Here

  public Object2ObjectFunction<Interval, MutableString> prefixMap() {
    if ( hasPrefixes && prefixMap == null ) prefixMap = new AbstractObject2ObjectFunction<Interval, MutableString>() {
      private static final long serialVersionUID = 1L;

      public boolean containsKey( Object o ) {
        Interval interval = (Interval)o;
        return interval != Intervals.EMPTY_INTERVAL && interval.left >= 0 && interval.right < RemotePrefixMap.this.size();
      }

      public MutableString get( Object o ) {
        final Interval interval = (Interval)o;
        try {
          ensureConnection();
          remoteConnection.outputStream.writeByte( RemotePrefixMap.GET_PREFIX );
          remoteConnection.outputStream.writeInt( interval.left );
          remoteConnection.outputStream.writeInt( interval.right );
View Full Code Here

   
    public void run() {
      try {
        final MutableString s = new MutableString();
        int command;
        Interval interval;

        for ( ;; ) {
          command = inputStream.readByte();
          if ( DEBUG ) LOGGER.debug( "Received remote command: " + command );
View Full Code Here

      for( int i = n; i-- != 0; ) intervalIterator[ i ].intervalTerms( terms );
    }

    public Interval nextInterval() throws IOException {
      if ( next != null ) {
        final Interval result = next;
        next = null;
        return result;
      }

      if ( endOfProcess ) return null;
View Full Code Here

      for( int i = n; i-- != 0; ) terms.add( indexIterator[ i ].termNumber() );
    }

    public Interval nextInterval() {
      if ( next != null ) {
        final Interval result = next;
        next = null;
        return result;
      }

      if ( endOfProcess ) return null;
View Full Code Here

    public Interval next() {
      if ( ! hasNext() ) throw new NoSuchElementException();
     
      if ( pos < cachedIntervals.size() ) return cachedIntervals.get( pos++ );
      else {
        final Interval next = intervalIterator.next();
        cachedIntervals.add( next );
        pos++;
        return next;
      }
    }
View Full Code Here

    }
   
    public Interval nextInterval() throws IOException {
      if ( pos < cachedIntervals.size() ) return cachedIntervals.get( pos++ );
      else {
        final Interval next = intervalIterator.nextInterval();
        if ( next == null ) return null;
        cachedIntervals.add( next );
        pos++;
        return next;
      }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.util.Interval

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.