Examples of IntIterator


Examples of edu.ucla.sspace.util.primitive.IntIterator

        edgeIndexer.lookup(0);

        // For each edge, find the most similar cluster updating the relative
        // indices of the rowToMostSimilar arrays with the results.
        Object taskKey = WORK_QUEUE.registerTaskGroup(g.order());
        IntIterator iter1 = g.vertices().iterator();
        while (iter1.hasNext()) {
            final int v1 = iter1.nextInt();
            WORK_QUEUE.add(taskKey, new Runnable() {
                    public void run() {
                        veryVerbose(LOGGER, "Computing similarities for " +
                                    "vertex %d", v1);
                        IntSet neighbors = g.getNeighbors(v1);
                        IntIterator it1 = neighbors.iterator();
                        while (it1.hasNext()) {
                            int v2 = it1.nextInt();
                            IntIterator it2 = neighbors.iterator();
                            while (it2.hasNext()) {
                                int v3 = it2.nextInt();
                                if (v2 == v3)
                                    break;
                                double sim = getConnectionSimilarity(
                                    g, v1, v2, v3);
View Full Code Here

Examples of edu.ucla.sspace.util.primitive.IntIterator

        edgeIndexer.lookup(0);

        // For each edge, find the most similar cluster updating the relative
        // indices of the rowToMostSimilar arrays with the results.
        Object taskKey = WORK_QUEUE.registerTaskGroup(g.order());
        IntIterator iter1 = g.vertices().iterator();
        while (iter1.hasNext()) {
            final int v1 = iter1.nextInt();
            WORK_QUEUE.add(taskKey, new Runnable() {
                    public void run() {
                        veryVerbose(LOGGER, "Computing similarities for " +
                                    "vertex %d", v1);
                        IntSet neighbors = g.getNeighbors(v1);
                        IntIterator it1 = neighbors.iterator();
                        while (it1.hasNext()) {
                            int v2 = it1.nextInt();
                            IntIterator it2 = neighbors.iterator();
                            while (it2.hasNext()) {
                                int v3 = it2.nextInt();
                                if (v2 == v3)
                                    break;
                                double sim = getConnectionSimilarity(
                                    g, v1, v2, v3);
                               
View Full Code Here

Examples of edu.ucla.sspace.util.primitive.IntIterator

        final PriorityQueue<EdgePair> pq =
            new PriorityQueue<EdgePair>(numComparisons);
        Object key = WORK_QUEUE.registerTaskGroup(graph.order());
       
        IntIterator iter1 = graph.vertices().iterator();
        while (iter1.hasNext()) {
            final int v1 = iter1.nextInt();
            WORK_QUEUE.add(key, new Runnable() {
                    public void run() {
                        veryVerbose(LOGGER, "Computing similarities for " +
                                    "vertex %d", v1);
                        //Set<E> adjList = graph.getAdjacencyList(v1);
                        IntSet neighbors = graph.getNeighbors(v1);
                        // Create a thread-local PriorityQueue that will hold
                        // the edge similarities for this vertex.  Once all the
                        // simialrites have been computed, we can update the
                        // thread-shared queue with minimal locking
                        PriorityQueue<EdgePair> localQ =
                            new PriorityQueue<EdgePair>(neighbors.size());
                        IntIterator it1 = neighbors.iterator();
                        // for (E e1 : adjList) {
                        while (it1.hasNext()) {
                            // int v2 = (e1.to() == v1) ? e1.from() : e1.to();
                            int v2 = it1.nextInt();
                           
                            IntIterator it2 = neighbors.iterator();
                            // for (Edge e2 : graph.getAdjacencyList(v1)) {
                            while (it2.hasNext()) {
                                int v3 = it2.nextInt();
                                if (v2 == v3)
                                    break;
                                // if (e1.equals(e2))
                                //     break;                              
                                // int v3 = (e2.to() == v1) ? e2.from() : e2.to();
View Full Code Here

Examples of edu.ucla.sspace.util.primitive.IntIterator

            impost1 = impost2;
            impost2 = t;
        }

        int inCommon = 0;
        IntIterator it = n1.iterator();
        while (it.hasNext()) {
            int v = it.nextInt();
            if (n2.contains(v))
                inCommon++;
        }

        if (n2.contains(impost1))
View Full Code Here

Examples of edu.ucla.sspace.util.primitive.IntIterator

                    copy.edges.put(v, iter.value());
            }
           
        }
        else {
            IntIterator iter = vertices.iterator();
            while (iter.hasNext()) {
                int v = iter.nextInt();
                if (edges.containsKey(v))
                    copy.edges.put(v, edges.get(v));
            }
        }
        return copy;
View Full Code Here

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

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

 
  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

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

   
    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

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

        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

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

    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
TOP
Copyright © 2018 www.massapi.com. 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.