public int numEntities() { TLongSet idSet = new TLongHashSet(); for (TLongObjectMap<Component> componentMap : store.values()) { idSet.addAll(componentMap.keys()); } return idSet.size(); }
TLongHashSet skipTiles = null; if (req.zoom >= 0 && req.zoom < 16) { skipTiles = new TLongHashSet(); skipTiles.clear(); long dy = skipVal - (dx << ZOOM_TO_SKIP_FILTER_READ); skipVal = ((dx >> dzoom) << ZOOM_TO_SKIP_FILTER) | (dy >> dzoom); if (skipVal != -1 && skipTiles.contains(skipVal)) { continue; req.zoom == -1 ? 31 : req.zoom + ZOOM_TO_SKIP_FILTER); if (read && skipVal != -1 && skipTiles != null) { skipTiles.add(skipVal);
/** {@inheritDoc} */ public long[] toArray() { long[] result = new long[ size() ]; long[] set = _set; byte[] states = _states; for ( int i = states.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { result[j++] = set[i]; } } return result; }
public void addImpassableRoads(Set<Long> impassableRoads) { if (impassableRoads != null && !impassableRoads.isEmpty()) { if (this.impassableRoads == null) { this.impassableRoads = new TLongHashSet(); } this.impassableRoads.addAll(impassableRoads); } } }
/** * Creates a new <code>TLongHashSet</code> instance that is a copy * of the existing set. * * @param collection a <tt>TLongSet</tt> that will be duplicated. */ public TLongHashSet( TLongCollection collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); if ( collection instanceof TLongHashSet ) { TLongHashSet hashset = ( TLongHashSet ) collection; this._loadFactor = hashset._loadFactor; this.no_entry_value = hashset.no_entry_value; //noinspection RedundantCast if ( this.no_entry_value != ( long ) 0 ) { Arrays.fill( _set, this.no_entry_value ); } setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); } addAll( collection ); }
@Override public double compare(final long[] h1, final long[] h2) { TLongHashSet union = new TLongHashSet(h1); union.addAll(h2); TLongHashSet intersection = new TLongHashSet(h1); intersection.retainAll(h2.clone()); //retainAll sorts the input, so we need to make a copy return 1.0 - (((double)intersection.size()) / (double)union.size()); } },
TLongHashSet seen = new TLongHashSet(); do { if (seen.size() == cardinality) return; // nothing can be done do { rval = a.ring.randomElement(rnd); } while (seen.contains(rval)); seen.add(rval); subs[i] = rval; } while (a.evaluate(i, subs[i]).isZero() || b.evaluate(i, subs[i]).isZero());
if(ro != null) { if(config.router.acceptLine(ro)) { if(excludeNotAllowed != null && !excludeNotAllowed.contains(ro.getId())) { ts.add(ro); excludeNotAllowed.add(ro.getId()); if(ts.excludedIds == null ){ ts.excludedIds = new TLongHashSet(); ts.excludedIds.add(ro.getId());
public void loadTileData(int x31, int y31, int zoomAround, final List<RouteDataObject> toFillIn) { int t = config.ZOOM_TO_LOAD_TILES - zoomAround; int coordinatesShift = (1 << (31 - config.ZOOM_TO_LOAD_TILES)); if(t <= 0) { t = 1; coordinatesShift = (1 << (31 - zoomAround)); } else { t = 1 << t; } TLongHashSet ts = new TLongHashSet(); long now = System.nanoTime(); for(int i = -t; i <= t; i++) { for(int j = -t; j <= t; j++) { ts.add(getRoutingTile(x31 +i*coordinatesShift, y31 + j*coordinatesShift, 0, OPTION_IN_MEMORY_LOAD)); } } TLongIterator it = ts.iterator(); TLongObjectHashMap<RouteDataObject> excludeDuplications = new TLongObjectHashMap<RouteDataObject>(); while(it.hasNext()){ getAllObjects(it.next(), toFillIn, excludeDuplications); } timeToFindInitialSegments += (System.nanoTime() - now); }
rp.findRouteSegment(lat, lon, ctx, listR); double distSquare = 0; TLongHashSet set = new TLongHashSet(); Set<String> streetNames = new HashSet<String>(); for (RouteSegmentPoint p : listR) { RouteDataObject road = p.getRoad(); if (!set.add(road.getId())) { continue;
/** {@inheritDoc} */ public boolean addAll( long[] array ) { boolean changed = false; for ( int i = array.length; i-- > 0; ) { if ( add( array[i] ) ) { changed = true; } } return changed; }
System.out.println("Took "+ time+" ms to find "+ validIDS.size()+" valid ids"); System.out.println("Reading ids in "+filename); BufferedReader br = new BufferedReader(new FileReader(filename), 128*1024); TLongHashSet ids = new TLongHashSet(); for(String line; (line = br.readLine())!=null;) ids.add(Long.parseLong(line)); System.out.println("Reading ids in "+filename); BufferedReader br = new BufferedReader(new FileReader(filename), 128*1024); TLongHashSet ids = new TLongHashSet(); for(String line; (line = br.readLine())!=null;) { long val = Long.parseLong(line); if (validSet.contains(val)) ids.add(val);
/** {@inheritDoc} */ public boolean containsAll( long[] array ) { for ( int i = array.length; i-- > 0; ) { if ( ! contains( array[i] ) ) { return false; } } return true; }
public int getCurrentMemberCount() { TLongHashSet knownMembers = new TLongHashSet(members.keySet()); knownMembers.removeAll(removedMembers); return knownMembers.size(); }
/** {@inheritDoc} */ public boolean removeAll( long[] array ) { boolean changed = false; for ( int i = array.length; i-- > 0; ) { if ( remove(array[i]) ) { changed = true; } } return changed; }
/** * Creates a new <code>TLongHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>long</code> primitives */ public TLongHashSet( long[] array ) { this( Math.max( array.length, DEFAULT_CAPACITY ) ); addAll( array ); }
/** {@inheritDoc} */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll( Collection<?> collection ) { boolean modified = false; TLongIterator iter = iterator(); while ( iter.hasNext() ) { if ( ! collection.contains( Long.valueOf ( iter.next() ) ) ) { iter.remove(); modified = true; } } return modified; }
@Override public Set<TDWay> getCoastLines(TileCoordinate tc) { if (tc.getZoomlevel() <= TileInfo.TILE_INFO_ZOOMLEVEL) { return Collections.emptySet(); } TileCoordinate correspondingOceanTile = tc.translateToZoomLevel(TileInfo.TILE_INFO_ZOOMLEVEL).get(0); if (this.wayIndexReader == null) { throw new IllegalStateException("way store not accessible, call complete() first"); } TLongHashSet coastlines = this.tilesToCoastlines.get(correspondingOceanTile); if (coastlines == null) { return Collections.emptySet(); } TLongIterator it = coastlines.iterator(); HashSet<TDWay> coastlinesAsTDWay = new HashSet<>(coastlines.size()); while (it.hasNext()) { long id = it.next(); TDWay tdWay = null; try { tdWay = TDWay.fromWay(this.wayIndexReader.get(id), this, this.preferredLanguages); } catch (NoSuchIndexElementException e) { LOGGER.finer("coastline way non-existing" + id); } if (tdWay != null) { coastlinesAsTDWay.add(tdWay); } } return coastlinesAsTDWay; }