Package gnu.trove.set.hash

Examples of gnu.trove.set.hash.TLongHashSet


     * @throws IOException
     */
    public long [] getNeighbors(long id, int beamRadius, int numPermutations) throws InvalidIndexException, IOException
    {
        if(numPermutations > maxPermutations) throw(new InvalidIndexException(reader.rootDir, "Max  available permutations is: " + maxPermutations + ". " + numPermutations + " were requested"));
        TLongHashSet sims = new TLongHashSet();
        if(!reader.permutationIndex.containsKey(id)) return null;
        int [] positions = reader.permutationIndex.get(id);
        if(maxPermutations != positions.length) throw(new InvalidIndexException(reader.rootDir, "Found invalid number of permutations: " + positions.length+ " for input id: " + id));
        for(int i = 0; i < numPermutations; i++)
        {
            getNeighbors(positions[i], beamRadius, permutationLists[i], sims);
        }       
        return sims.toArray();
    }
View Full Code Here


        assertTrue( values.containsAll( java_set ) );
        java_set.add( Long.valueOf( 12 ) );
        assertFalse( values.containsAll( java_set ) );

        // test with a TCollection
        TLongSet tintset = new TLongHashSet( vals );
        assertTrue( values.containsAll( tintset ) );
        tintset.add( 12 );
        assertFalse( values.containsAll( tintset ) );

        // test raw array
        assertTrue( values.containsAll( vals ) );
        vals[3] = vals[3] + 1;
View Full Code Here

        assertFalse( values.isEmpty() );

        assertFalse( values.retainAll( values ) );

        // test with a TCollection
        TLongSet tintset = new TLongHashSet( vals );
        assertFalse( "values: " + values + ", collection: " + tintset,
                values.retainAll( tintset ) );
        TLongCollection collection = new TLongArrayList( vals );
        assertFalse( "values: " + values + ", collection: " + collection,
                values.retainAll( collection ) );
View Full Code Here

            map.put( keys[i], vals[i] );
        }
        values = map.valueCollection();

        // With empty set
        TLongSet tlongset = new TLongHashSet();
        assertFalse( "values: " + values + ", collection: " + tlongset,
                values.removeAll( tlongset ) );

        // With partial set
        tlongset = new TLongHashSet( vals );
        tlongset.remove( 42 * 2 );
        assertTrue( "values: " + values + ", collection: " + tlongset,
                values.removeAll( tlongset ) );
        assertEquals( "set: " + values, 1, values.size() );
        assertEquals( "set: " + values, 1, map.size() );
        for ( int i = 0; i < keys.length; i++ ) {
View Full Code Here

        rollbackLog = rollback ? new TLongObjectHashMap<RollbackInfo>() : null;
    }

    synchronized void add(long id) {
        if (ls == null)
            ls = new TLongHashSet();
        ls.add(id);
        if (lines == null)
            lines = ls;
        else if (lines != ls)
            ((TLongCompoundCollection) lines).addCollection(ls);
View Full Code Here

*/
public class TIntPairHashSet {
  private TLongHashSet set;

  public TIntPairHashSet() {
    set = new TLongHashSet(100);
  }
View Full Code Here

  public TIntPairHashSet() {
    set = new TLongHashSet(100);
  }

  public TIntPairHashSet(int capacity) {
    set = new TLongHashSet(capacity);
  }
View Full Code Here

        nObjects++;
    }

    public final void insert(LineString geom, final Object item) {
        Coordinate[] coord = geom.getCoordinates();
        final TLongSet keys = new TLongHashSet(coord.length * 8);
        for (int i = 0; i < coord.length - 1; i++) {
            // TODO Cut the segment if longer than bin size
            // to reduce the number of wrong bins
            Envelope env = new Envelope(coord[i], coord[i + 1]);
            visit(env, true, new BinVisitor<T>() {
                @Override
                public boolean visit(List<T> bin, long mapKey) {
                    keys.add(mapKey);
                    return false;
                }
            });
        }
        keys.forEach(new TLongProcedure() {
            @SuppressWarnings("unchecked")
            @Override
            public boolean execute(long key) {
                // Note: bins have been initialized in the previous visit
                bins.get(key).add((T) item);
View Full Code Here

        rollbackLog = rollback ? new TLongObjectHashMap<RollbackInfo>() : null;
    }

    synchronized void add(long id) {
        if (ls == null)
            ls = new TLongHashSet();
        ls.add(id);
        if (lines == null)
            lines = ls;
        else if (lines != ls)
            ((TLongCompoundCollection) lines).addCollection(ls);
View Full Code Here

  /**
   * Test trove4j's implementation
   */
  @Test
  public void troveLongSet() {
    TLongHashSet set = new TLongHashSet(values.length * 3 / 2);
    for (int i = 0; i < values.length; ++i) {
      set.add(values[i]);
    }
   
    for (int i = 0; i < values.length; ++i) {
      assertTrue(set.contains(values[i]));
    }
   
    for (int i = 0; i < values.length; ++i) {
      set.remove(values[i]);
    }
  }
View Full Code Here

TOP

Related Classes of gnu.trove.set.hash.TLongHashSet

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.