Package it.unimi.dsi.fastutil.ints

Examples of it.unimi.dsi.fastutil.ints.IntIterator


 
  protected int combineSizes( final OutputBitStream sizesOutputBitStream ) throws IOException {
    int maxDocSize = 0, currDoc = 0;
    if ( needsSizes ) size = new int[ numberOfDocuments ];
    for( int i = 0; i < numIndices; i++ ) {
      final IntIterator sizes = sizes( i );
      int s = 0;
      int j = index[ i ].numberOfDocuments;
      while( j-- != 0 ) {
        maxDocSize = Math.max( maxDocSize, s = sizes.nextInt() );
        if ( needsSizes ) size[ currDoc++ ] = s;
        sizesOutputBitStream.writeGamma( s );
      }
      if ( sizes instanceof Closeable ) ((Closeable)sizes).close();
    }
View Full Code Here


 
  protected int combineSizes( final OutputBitStream sizesOutputBitStream ) throws IOException {
    int currDoc = 0, maxDocSize = 0;
    size = new int[ numberOfDocuments ];
    for( int i = 0; i < numIndices; i++ ) {
      final IntIterator sizes = sizes( i );

      currDoc = 0;
      int j = index[ i ].numberOfDocuments;
      int s;
      while( j-- != 0 ) {
        if ( ( s = sizes.nextInt() ) != 0 ) {
          if ( size[ currDoc ] != 0 ) throw new IllegalArgumentException( "Document " + currDoc + " has nonzero length in two indices" );
          size[ currDoc ] = s;
          if ( s > maxDocSize ) maxDocSize = s;
        }
        currDoc++;
View Full Code Here

   
    if ( incremental ) {
      // We accumulate document sizes in an array.
      size = new int[ numberOfDocuments ];
      for( int i = 0; i < numIndices; i++ ) {
        final IntIterator sizes = sizes( i );
        int j = index[ i ].numberOfDocuments;
        currDoc = 0;
        while( j-- != 0 ) maxDocSize = Math.max( maxDocSize, size[ currDoc++ ] += sizes.nextInt() );
        if ( sizes instanceof Closeable ) ((Closeable)sizes).close();
      }
      // We write the array.
      for( int s: size ) sizesOutputBitStream.writeGamma( s );
      // We keep it if we need sizes.
      if ( ! needsSizes ) size = null;
    }
    else {
      if ( needsSizes ) size = new int[ numberOfDocuments ];
      final IntIterator sizes = sizes( numIndices - 1 );
      int s = 0;
      // We copy the last file size, and store the elements in an array if needsSizes is true.
      for( int j = 0; j < numberOfDocuments; j++ ) {
        s = sizes.nextInt();
        if ( needsSizes ) size[ j ] = s;
        maxDocSize = Math.max( maxDocSize, s );
        sizesOutputBitStream.writeGamma( s );
      }
      if ( sizes instanceof Closeable ) ((Closeable)sizes).close();
View Full Code Here

        secondIterator = !textTerm?secondIndexReader.documents(i):secondIndexReader.documents(firstIndex.termMap.list().get(i));       
        while(firstIterator.hasNext()){
          firstIterator.next();
          secondIterator.next();
 
          IntIterator firstIntIt = firstIterator.positions();
          IntIterator secondIntIt = secondIterator.positions();       
          while(firstIntIt.hasNext()){                 
            Assert.assertEquals(firstIntIt.nextInt(),secondIntIt.nextInt());
          }       
          Assert.assertEquals(firstIntIt.skip(2),secondIntIt.skip(2));       
          if(firstIntIt.hasNext()){
            Assert.assertEquals(firstIntIt.nextInt(),secondIntIt.nextInt());
          }       
          Assert.assertEquals(firstIntIt.skip(9999999),secondIntIt.skip(9999999));       
          if(firstIntIt.hasNext()){       
            Assert.assertEquals(firstIntIt.nextInt(),secondIntIt.nextInt());
          }
         
        }
       
        /** Compare IntervalIterator from Interval() method */
 
View Full Code Here

    if ( ! jsapResult.getBoolean( "noComp" ) ) {
      IndexReader additionalReader;
      IntLinkedOpenHashSet s0 = new IntLinkedOpenHashSet();
      IntOpenHashSet s1 = new IntOpenHashSet();
      IntAVLTreeSet s2 = new IntAVLTreeSet();
      IntIterator it;
      IndexIterator indexIterator, additionalIterator;
      it.unimi.dsi.mg4j.search.DocumentIterator documentIterator;
      int u = 0;
     
      try {
        for (i = 0; i < index.length; i++) {
          pl.expectedUpdates = numberOfTerms[ i ];
          pl.start("Verifying composite iterators in " + index[i] + "...");
          additionalReader = index[ i ].getReader();
         
          for (t = 0; t < numberOfTerms[ i ]; t++) {
            for (u = 0; u < numberOfTerms[ i ]; u++) {
              s0.clear();
              s1.clear();
              // TODO: in case we have positions, we should check them, too
              IntIterators.pour( termLists ? indexReader[ i ].documents( terms[ i ].get( t ) ) : indexReader[ i ].documents( t ), s0 );
              IntIterators.pour( termLists ? indexReader[ i ].documents( terms[ i ].get( u ) ) : indexReader[ i ].documents( u ), s1 );
              s0.retainAll( s1 );
              indexIterator =  termLists ? indexReader[ i ].documents( terms[ i ].get( t ) ) : indexReader[ i ].documents( t );
              additionalIterator = termLists ? additionalReader.documents( terms[ i ].get( u ) ) : additionalReader.documents( u );
              it = s0.iterator();
              documentIterator = AndDocumentIterator.getInstance( indexIterator, additionalIterator );
              for( int j = s0.size(); j-- != 0; ) if ( it.nextInt() != documentIterator.nextDocument() ) throw new AssertionError();
              if ( documentIterator.hasNext() ) throw new AssertionError();

              s2.clear();
              IntIterators.pour( termLists ? indexReader[ i ].documents( terms[ i ].get( t ) ) : indexReader[ i ].documents( t ), s2 );
              IntIterators.pour( termLists ? indexReader[ i ].documents( terms[ i ].get( u ) ) : indexReader[ i ].documents( u ), s2 );

              indexIterator =  termLists ? indexReader[ i ].documents( terms[ i ].get( t ) ) : indexReader[ i ].documents( t );
              additionalIterator = termLists ? additionalReader.documents( terms[ i ].get( u ) ) : additionalReader.documents( u );

              it = s2.iterator();
              documentIterator = OrDocumentIterator.getInstance( indexIterator, additionalIterator );
              for( int j = s2.size(); j-- != 0; ) if ( it.nextInt() != documentIterator.nextDocument() ) throw new AssertionError();
              if ( documentIterator.hasNext() ) throw new AssertionError();
           
            pl.update();
          }
          pl.done();
View Full Code Here

    assertEquals( 3, position[ 3 ] );

   
    assertEquals( Interval.valueOf( 3 ), multiTermIndexIterator.intervalIterator().nextInterval() );

    IntIterator positions = multiTermIndexIterator.positions();
    assertEquals( 0, positions.nextInt() );
    assertEquals( 1, positions.nextInt() );
    assertEquals( 2, positions.nextInt() );
    assertEquals( 3, positions.nextInt() );
    assertFalse( positions.hasNext() );

   
    assertFalse( multiTermIndexIterator.intervalIterator().hasNext() );
    assertFalse( multiTermIndexIterator.intervalIterator().hasNext() ); // To increase coverage

    assertEquals( 1, multiTermIndexIterator.nextDocument() );
    assertTrue( multiTermIndexIterator.intervalIterator().hasNext() );
    assertTrue( multiTermIndexIterator.intervalIterator().hasNext() ); // To increase coverage
    assertEquals( Interval.valueOf( 0 ), multiTermIndexIterator.intervalIterator().nextInterval() );
    assertEquals( Interval.valueOf( 2 ), multiTermIndexIterator.intervalIterator().nextInterval() );

    assertEquals( 2, multiTermIndexIterator.count() );
    position = multiTermIndexIterator.positionArray();
    assertEquals( 0, position[ 0 ] );
    assertEquals( 2, position[ 1 ] );
    positions = multiTermIndexIterator.positions();
    assertEquals( 0, positions.nextInt() );
    assertEquals( 2, positions.nextInt() );
    assertFalse( positions.hasNext() );
   
    assertFalse( multiTermIndexIterator.intervalIterator().hasNext() );

    assertEquals( 2, multiTermIndexIterator.nextDocument() );
    assertTrue( multiTermIndexIterator.intervalIterator().hasNext() );
    assertTrue( multiTermIndexIterator.intervalIterator().hasNext() ); // To increase coverage
    assertEquals( Interval.valueOf( 0 ), multiTermIndexIterator.intervalIterator().nextInterval() );
    assertEquals( Interval.valueOf( 1 ), multiTermIndexIterator.intervalIterator().nextInterval() );

    assertEquals( 2, multiTermIndexIterator.count() );
    position = multiTermIndexIterator.positionArray();
    assertEquals( 0, position[ 0 ] );
    assertEquals( 1, position[ 1 ] );
    positions = multiTermIndexIterator.positions();
    assertEquals( 0, positions.nextInt() );
    assertEquals( 1, positions.nextInt() );
    assertFalse( positions.hasNext() );
   
    assertFalse( multiTermIndexIterator.intervalIterator().hasNext() );
   
    // Here we get the iterator of the underlying IndexIterator
    assertEquals( 3, multiTermIndexIterator.nextDocument() );
    assertTrue( multiTermIndexIterator.intervalIterator().hasNext() );
    assertEquals( Interval.valueOf( 0 ), multiTermIndexIterator.intervalIterator().nextInterval() );

    assertEquals( 1, multiTermIndexIterator.count() );
    position = multiTermIndexIterator.positionArray();
    assertEquals( 0, position[ 0 ] );
    positions = multiTermIndexIterator.positions();
    assertEquals( 0, positions.nextInt() );
    assertFalse( positions.hasNext() );
   
    assertFalse( multiTermIndexIterator.intervalIterator().hasNext() );
   
    // The end
    assertFalse( multiTermIndexIterator.hasNext() );
View Full Code Here

    mask |= (mask >> 4);
    mask |= (mask >> 8);
    mask |= (mask >> 16);
    _mask = mask;
    _filter = new long[mask+1];
    IntIterator iter = set.iterator();
    while(iter.hasNext())
    {
      int h = iter.nextInt() * MIXER;
     
      long bits = _filter[h & _mask];
      bits |= ((1L << (h >>> 26)));
      bits |= ((1L << ((h >> 20) & 0x3F)));
      _filter[h & _mask] = bits;
View Full Code Here

    return true;
  }

  public boolean containsAll(IntCollection c)
  {
    final IntIterator i = c.iterator();
    int n = c.size();
    while(n-- != 0) if (!contains(i.nextInt())) return false;
    return true;
  }
View Full Code Here

  }

  @Override
  public void write(DataOutput out) throws IOException {
    out.writeInt(neighbors.size());
    IntIterator iterator = neighbors.iterator();
    while (iterator.hasNext()) {
      out.writeInt(iterator.nextInt());
    }
  }
View Full Code Here

     * @param iter An iterator of items to remove (in sorted order).
     * @return {@code true} if any items were removed.
     */
    private boolean removeAll(LongIterator iter) {
        boolean removed = false;
        IntIterator posIter = keys.activeIndexIterator(true);
        int idx = posIter.hasNext() ? posIter.nextInt() : -1;
        while (iter.hasNext() && idx >= 0) {
            long rmk = iter.nextLong();
            // advance position pointer looking for this item
            while (idx >= 0 && keys.getKey(idx) < rmk) {
                idx = posIter.hasNext() ? posIter.nextInt() : -1;
            }
            // remove if necessary
            if (idx >= 0 && keys.getKey(idx) == rmk) {
                keys.setActive(idx, false);
                removed = true;
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.ints.IntIterator

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.