Java 类gnu.trove.map.hash.TLongObjectHashMap 实例源码

项目:ProjectAres    文件:FallingBlocksMatchModule.java   
private void disturb(long pos, BlockState blockState, @Nullable ParticipantState disturber) {
    FallingBlocksRule rule = this.ruleWithShortestDelay(blockState);
    if(rule != null) {
        long tick = this.getMatch().getClock().now().tick + rule.delay;
        TLongObjectMap<ParticipantState> blockDisturbers = this.blockDisturbersByTick.get(tick);

        if(blockDisturbers == null) {
            blockDisturbers = new TLongObjectHashMap<>();
            this.blockDisturbersByTick.put(tick, blockDisturbers);
        }

        Block block = blockState.getBlock();
        if(!blockDisturbers.containsKey(pos)) {
            blockDisturbers.put(pos, disturber);
        }
    }
}
项目:graphium    文件:RenderingCalculatorImpl.java   
@Override
public void calculateAllReduceFactors(final TLongObjectMap<TLongArrayList> nodeSegmentTable,
                                      final TLongObjectMap<ISegment> segmentsTable,
                                      final TLongSet relevantLinks,
                                      TLongObjectMap<IPixelCut> pixelCuts) {
    TLongObjectMap<IRenderingSegment> renderingResults = new TLongObjectHashMap<>();
    nodeSegmentTable.forEachEntry((nodeId, segmentIds) -> {
        if (segmentIds.size() > 1) {
            ISegment[] segments = new ISegment[segmentIds.size()];
            for (int i = 0; i < segmentIds.size(); i++) {
                segments[i] = segmentsTable.get(segmentIds.get(i));
            }
            investigateNode(nodeId, renderingResults, segments);
        }
        return true;
    });
    adaptPixelCuts(pixelCuts, renderingResults);
}
项目:graphium    文件:WaySink.java   
public WaySink(TLongObjectHashMap<List<WayRef>> wayRefs, TLongObjectHashMap<NodeCoord> nodes, 
        TLongObjectHashMap<List<IWaySegment>> segmentedWaySegments, TLongObjectHashMap<List<Relation>> wayRelations,
        BlockingQueue<IWaySegment> waysQueue) {
    this.wayRefs = wayRefs;
    this.nodes = nodes;
    this.wayRelations = wayRelations;
    this.segmentedWaySegments = segmentedWaySegments;
    for (long nodeId : wayRefs.keys()) {
        List<WayRef> wayRefList = wayRefs.get(nodeId);
        for (WayRef wayRef : wayRefList) {
            if (wayRef.getType() == 2) {
                if (waysToSegment.get(wayRef.getWayId()) == null) {
                    waysToSegment.put(wayRef.getWayId(), new TLongArrayList(new long[] {nodeId}));
                } else {
                    waysToSegment.get(wayRef.getWayId()).add(nodeId);
                }
            }
        }
    }

    this.waysQueue = waysQueue;
    this.connectionsBuilder = new ConnectionsBuilder();
}
项目:graphium    文件:SegmentationWaySink.java   
public SegmentationWaySink(TLongObjectHashMap<List<WayRef>> wayRefs, TLongObjectHashMap<List<Relation>> wayRelations, 
        BlockingQueue<IWaySegment> waysQueue) {
    this.wayRefs = wayRefs;
    this.wayRelations = wayRelations;
    for (long nodeId : wayRefs.keys()) {
        List<WayRef> wayRefList = wayRefs.get(nodeId);
        for (WayRef wayRef : wayRefList) {
            if (wayRef.getType() == 2) {
                if (waysToSegment.get(wayRef.getWayId()) == null) {
                    waysToSegment.put(wayRef.getWayId(), new TLongArrayList(new long[] {nodeId}));
                } else {
                    waysToSegment.get(wayRef.getWayId()).add(nodeId);
                }
            }
        }
    }

    this.waysQueue = waysQueue;
    connectionsBuilder = new ConnectionsBuilder();
}
项目:discord-bot-gateway    文件:CachedChannel.java   
@Override
public void update(JSONObject json) {
    position = json.optInt("position");
    if(overwrites == null) overwrites = new TLongObjectHashMap<>();
    TLongSet toRemove = new TLongHashSet(overwrites.keys());
    JSONArray array = json.getJSONArray("permission_overwrites");
    for(int i = 0, j = array.length(); i < j; i++) {
        JSONObject overwrite = array.getJSONObject(i);
        long id = overwrite.getLong("id");
        toRemove.remove(id);
        overwrites.put(id, new CachedOverwrite(overwrite));
    }
    for(TLongIterator it = toRemove.iterator(); it.hasNext();) {
        overwrites.remove(it.next());
    }
    name = json.optString("name");
    topic = json.optString("topic");
    nsfw = json.optBoolean("nsfw");
    lastMessageId = json.optLong("last_message_id");
    bitrate = json.optInt("bitrate");
    userLimit = json.optInt("user_limit");
    parentId = json.optLong("parent_id");
}
项目:Hard-Science    文件:CSGNode.java   
/**
 * Returns all quads in this tree recombined as much as possible.
 * Use instead of allRawQuads() for anything to be rendered.
 * Generally only useful on job node!
 * 
 * Will only work if build was called with initCSG parameter = true
 * during initialization of the tree because it uses the information populated then.
 * @return
 */
public List<RawQuad> recombinedRawQuads()
{
    TLongObjectHashMap<ArrayList<RawQuad>> ancestorBuckets = new TLongObjectHashMap<ArrayList<RawQuad>>();

    this.allRawQuads().forEach((quad) -> 
    {
        if(!ancestorBuckets.contains(quad.ancestorQuadID))
        {
            ancestorBuckets.put(quad.ancestorQuadID, new ArrayList<RawQuad>());
        }
        ancestorBuckets.get(quad.ancestorQuadID).add(quad);
    });

    ArrayList<RawQuad> retVal = new ArrayList<RawQuad>();
    ancestorBuckets.valueCollection().forEach((quadList) ->
    {
        retVal.addAll(recombine(quadList));
    });

    return retVal;
}
项目:G    文件:TxtGraphUtils.java   
public static TLongObjectHashMap loadLong2TXTGZMap(String mapFile, boolean reverse) throws IOException {
    long time = System.currentTimeMillis();
    TLongObjectHashMap idMap = new TLongObjectHashMap();
    BufferedReader br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(mapFile))));
    String line;
    String[] parts;

    while ((line = br.readLine()) != null) {
        parts = line.split(SEP);
        if (!reverse) {
            idMap.put(Long.parseLong(parts[0]), parts[1]);
        } else {
            idMap.put(Long.parseLong(parts[1]), parts[0]);
        }
    }

    logger.info(((System.currentTimeMillis() - time) / 1000d) + "s");
    return idMap;
}
项目:mapsforge    文件:HDTileBasedDataProcessor.java   
private HDTileBasedDataProcessor(MapWriterConfiguration configuration) {
    super(configuration);
    this.indexedNodeStore = new IndexedObjectStore<Node>(new SingleClassObjectSerializationFactory(Node.class),
            "idxNodes");
    this.indexedWayStore = new IndexedObjectStore<Way>(new SingleClassObjectSerializationFactory(Way.class),
            "idxWays");
    // indexedRelationStore = new IndexedObjectStore<Relation>(
    // new SingleClassObjectSerializationFactory(
    // Relation.class), "idxWays");
    this.wayStore = new SimpleObjectStore<Way>(new SingleClassObjectSerializationFactory(Way.class), "heapWays",
            true);
    this.relationStore = new SimpleObjectStore<Relation>(new SingleClassObjectSerializationFactory(Relation.class),
            "heapRelations", true);

    this.tileData = new HDTileData[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()][][];
    for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) {
        this.tileData[i] = new HDTileData[this.tileGridLayouts[i].getAmountTilesHorizontal()][this.tileGridLayouts[i]
                .getAmountTilesVertical()];
    }
    this.virtualWays = new TLongObjectHashMap<TDWay>();
    this.additionalRelationTags = new TLongObjectHashMap<List<TDRelation>>();
}
项目:JMaNGOS    文件:ItemStorages.java   
/**
 * 
 * @see org.jmangos.commons.dataholder.DataLoadService#load()
 */
@Override
public TLongObjectHashMap<ItemPrototype> load() {

    Long eTime = System.currentTimeMillis();

    final TLongObjectHashMap<ItemPrototype> map = new TLongObjectHashMap<ItemPrototype>();
    final List<ItemPrototype> itemPrototypeList =
            this.itemPrototypeService.readItemPrototypes();

    // Fill map
    for (final ItemPrototype item : itemPrototypeList) {
        map.put(item.getEntry(), item);
    }

    eTime = System.currentTimeMillis() - eTime;
    ItemStorages.logger.info(String.format("Loaded [%d] ItemPrototypes under %d ms",
            map.size(), eTime));

    this.itemPrototypes = map;
    return this.itemPrototypes;
}
项目:ProjectAres    文件:FallingBlocksMatchModule.java   
/**
 * Make any unsupported blocks fall that are disturbed for the current tick
 */
private void fallCheck() {
    this.visitsWorstTick = Math.max(this.visitsWorstTick, this.visitsThisTick);
    this.visitsThisTick = 0;

    World world = this.getMatch().getWorld();
    TLongObjectMap<ParticipantState> blockDisturbers = this.blockDisturbersByTick.remove(this.getMatch().getClock().now().tick);
    if(blockDisturbers == null) return;

    TLongSet supported = new TLongHashSet();
    TLongSet unsupported = new TLongHashSet();
    TLongObjectMap<ParticipantState> fallsByBreaker = new TLongObjectHashMap<>();

    try {
        while(!blockDisturbers.isEmpty()) {
            long pos = blockDisturbers.keySet().iterator().next();
            ParticipantState breaker = blockDisturbers.remove(pos);

            // Search down for the first block that can actually fall
            for(;;) {
                long below = neighborPos(pos, BlockFace.DOWN);
                if(!Materials.isColliding(blockAt(world, below).getType())) break;
                blockDisturbers.remove(pos); // Remove all the blocks we find along the way
                pos = below;
            }

            // Check if the block needs to fall, if it isn't already falling
            if(!fallsByBreaker.containsKey(pos) && !this.isSupported(pos, supported, unsupported)) {
                fallsByBreaker.put(pos, breaker);
            }
        }
    } catch(MaxSearchVisitsExceeded ex) {
        this.logError(ex);
    }

    for(TLongObjectIterator<ParticipantState> iter = fallsByBreaker.iterator(); iter.hasNext();) {
        iter.advance();
        this.fall(iter.key(), iter.value());
    }
}
项目:graphium    文件:RelationSink.java   
public RelationSink(TLongObjectHashMap<List<WayRef>> wayRefs) {
    for (List<WayRef> wayRefList : wayRefs.valueCollection()) {
        for (WayRef wayRef : wayRefList) {
            wayIds.add(wayRef.getWayId());
        }
    }
}
项目:graphium    文件:GipLinkSectionParser.java   
public GipLinkSectionParser(IGipParser parserReference,
                            IGipSectionParser<TLongObjectMap<IGipNode>> nodeParser,
                            IImportConfig config,
                            ImportStatistics statistics) {
    super(parserReference);
    this.links = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>());
    this.nodeParser = nodeParser;
    this.functionalRoadClasses = config.getFrcList();
    this.accessTypes = config.getAccessTypes();
    this.executor = Executors.newFixedThreadPool(15);
    this.statistics = statistics;
}
项目:graphium    文件:GipParserImpl.java   
private TLongObjectMap<IPixelCut> calculatePixelCutOffset(IImportConfig config,
                                                              TLongSet linkIdsEnqueued,
                                                              TLongObjectMap<IGipLink> links){
    log.info("phase pixel cut calculation ....");
    TLongObjectMap<IPixelCut> renderingResultPerSegment = new TLongObjectHashMap<>();
    final TLongObjectHashMap<TLongArrayList> nodeLinksConnectionTable = new TLongObjectHashMap<>();
    log.info("Link Ids Queued size: " + linkIdsEnqueued.size());
    GipLinkFilter filter = new GipLinkFilter(config.getMaxFrc(),config.getMinFrc(),config.getIncludedGipIds(),
            config.getExcludedGipIds(),config.isEnableSmallConnections());
    TLongSet filteredLinks = filter.filter(links);
    linkIdsEnqueued.forEach(value -> {
        //enqued Gip Links that after they have been filtered.
        if (filteredLinks.contains(value)) {
            IGipLink link = links.get(value);
            if (link != null) {
                if (link.getFromNodeId() != 0) {
                    if (!nodeLinksConnectionTable.containsKey(link.getFromNodeId())) {
                        nodeLinksConnectionTable.put(link.getFromNodeId(), new TLongArrayList());
                    }
                    nodeLinksConnectionTable.get(link.getFromNodeId()).add(link.getId());
                }
                if (link.getToNodeId() != 0) {
                    if (!nodeLinksConnectionTable.containsKey(link.getToNodeId())) {
                        nodeLinksConnectionTable.put(link.getToNodeId(), new TLongArrayList());
                    }
                    nodeLinksConnectionTable.get(link.getToNodeId()).add(link.getId());
                }
            }
        }
        return true;
    });

    log.info("Filtered Links Size " + filteredLinks.size());
    renderingResultPerSegment = new TLongObjectHashMap<>();
    IRenderingCalculator renderingCalculator = new RenderingCalculatorImpl();
    renderingCalculator.calculateAllReduceFactors(nodeLinksConnectionTable, adaptSegments(links), filteredLinks, renderingResultPerSegment);
    log.info("Rendering result size " + renderingResultPerSegment.size());
    return renderingResultPerSegment;
}
项目:graphium    文件:GipParserImpl.java   
private TLongObjectMap<ISegment> adaptSegments(TLongObjectMap<IGipLink> links) {
    TLongObjectMap<ISegment> segments = new TLongObjectHashMap<>(links.size());
    for (Long id : links.keys()) {
        IGipLink link = links.get(id);
        segments.put(id, new SegmentImpl(link.getId(), link.getFromNodeId(), link.getToNodeId(), link.getCoordinatesX(), link.getCoordinatesY(), link.getFuncRoadClassValue()));
    }
    return segments;
}
项目:graphium    文件:GipLinkTurnEdgesParser.java   
public GipLinkTurnEdgesParser(IGipParser parserReference, IImportConfig config,
                              IGipSectionParser<TLongObjectMap<IGipNode>> nodeParser,
                              IGipSectionParser<TLongObjectMap<IGipLink>> linkParser,
                              IGipSectionParser<TLongSet> linkCoordinateParser) {
    super(parserReference);
    this.config = config;
    this.nodeParser = nodeParser;
    this.linkParser = linkParser;
    this.linkCoordinateParser = linkCoordinateParser;
    this.turnEdges = new TLongObjectHashMap<>();
}
项目:Long-Map-Benchmarks    文件:MapTests.java   
@Benchmark
public void manualSnchronizedTLongObjectHashMapGet(Context context) {
    TLongObjectHashMap<Object> map = new TLongObjectHashMap<>();

    synchronized (map) {
        troveMapGet(context, map);
    }
}
项目:Long-Map-Benchmarks    文件:MapTests.java   
@Benchmark
public void manualSnchronizedTLongObjectHashMapUpdate(Context context) {
    TLongObjectHashMap<Object> map = new TLongObjectHashMap<>();

    synchronized (map) {
        troveMapPutUpdate(context, map);
    }
}
项目:Long-Map-Benchmarks    文件:MapTests.java   
@Benchmark
public void manualSnchronizedTLongObjectHashMapPutRemove(Context context) {
    TLongObjectHashMap<Object> map = new TLongObjectHashMap<>();

    synchronized (map) {
        troveMapPutRemove(context, map);
    }
}
项目:Long-Map-Benchmarks    文件:MapTests.java   
@Benchmark
public TLongObjectHashMap manualSnchronizedTLongObjectHashMapMapCopy(Context context) {
    TLongObjectHashMap<Object> map = new TLongObjectHashMap<>();

    synchronized (map) {
        //Populate the map the first time
        for (int i = 0; i < context.testValues.length; i++)
            map.put(context.testKeys[i], context.testValues[i]);

        //Copy!
        TLongObjectHashMap<Object> copy = new TLongObjectHashMap<>(map);
        return copy;
    }
}
项目:Long-Map-Benchmarks    文件:MapTests.java   
@Benchmark
public void synchronizedTLongObjectHashMapGet(Context context) {
    TSynchronizedLongObjectMap<Object> map = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>());

    synchronized (map) {
        troveMapGet(context, map);
    }
}
项目:Long-Map-Benchmarks    文件:MapTests.java   
@Benchmark
public void synchronizedTLongObjectHashMapUpdate(Context context) {
    TSynchronizedLongObjectMap<Object> map = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>());

    synchronized (map) {
        troveMapPutUpdate(context, map);
    }
}
项目:Long-Map-Benchmarks    文件:MapTests.java   
@Benchmark
public void synchronizedTLongObjectHashMapPutRemove(Context context) {
    TSynchronizedLongObjectMap<Object> map = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>());

    synchronized (map) {
        troveMapPutRemove(context, map);
    }
}
项目:Long-Map-Benchmarks    文件:MapTests.java   
@Benchmark
public TSynchronizedLongObjectMap synchronizedTLongObjectHashMapMapCopy(Context context) {
    TSynchronizedLongObjectMap<Object> map = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>());

    synchronized (map) {
        //Populate the map the first time
        for (int i = 0; i < context.testValues.length; i++)
            map.put(context.testKeys[i], context.testValues[i]);

        //Copy!
        TSynchronizedLongObjectMap<Object> copy = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>(map));
        return copy;
    }
}
项目:financisto1-holo    文件:CurrencyCache.java   
public static synchronized void initialize(EntityManager em) {
       TLongObjectHashMap<Currency> currencies = new TLongObjectHashMap<Currency>();
    Query<Currency> q = em.createQuery(Currency.class);
    Cursor c = q.execute();
    try {
        while (c.moveToNext()) {
            Currency currency = EntityManager.loadFromCursor(c, Currency.class);
            currencies.put(currency.id, currency);
        }
    } finally {
        c.close();
    }
    CURRENCIES.putAll(currencies);
}
项目:financisto1-holo    文件:LatestExchangeRates.java   
private TLongObjectMap<ExchangeRate> getMapFor(long fromCurrencyId) {
    TLongObjectMap<ExchangeRate> m = rates.get(fromCurrencyId);
    if (m == null) {
        m = new TLongObjectHashMap<ExchangeRate>();
        rates.put(fromCurrencyId, m);
    }
    return m;
}
项目:financisto1-holo    文件:HistoryExchangeRates.java   
private TLongObjectMap<SortedSet<ExchangeRate>> getMapFor(long fromCurrencyId) {
    TLongObjectMap<SortedSet<ExchangeRate>> m = rates.get(fromCurrencyId);
    if (m == null) {
        m = new TLongObjectHashMap<SortedSet<ExchangeRate>>();
        rates.put(fromCurrencyId, m);
    }
    return m;
}
项目:GabrielBot    文件:GabrielBot.java   
public TLongObjectMap<GuildMusicPlayer> getPlayers() {
    TLongObjectMap<GuildMusicPlayer> map = new TLongObjectHashMap<>();
    for(Shard s : shards) {
        map.putAll(s.players());
    }
    return map;
}
项目:flowzr-android-black    文件:CurrencyCache.java   
public static synchronized void initialize(EntityManager em) {
       TLongObjectHashMap<Currency> currencies = new TLongObjectHashMap<Currency>();
    Query<Currency> q = em.createQuery(Currency.class);
    Cursor c = q.execute();
    try {
        while (c.moveToNext()) {
            Currency currency = EntityManager.loadFromCursor(c, Currency.class);
            currencies.put(currency.id, currency);
        }
    } finally {
        c.close();
    }
    CURRENCIES.putAll(currencies);
}
项目:flowzr-android-black    文件:LatestExchangeRates.java   
private TLongObjectMap<ExchangeRate> getMapFor(long fromCurrencyId) {
    TLongObjectMap<ExchangeRate> m = rates.get(fromCurrencyId);
    if (m == null) {
        m = new TLongObjectHashMap<>();
        rates.put(fromCurrencyId, m);
    }
    return m;
}
项目:flowzr-android-black    文件:HistoryExchangeRates.java   
private TLongObjectMap<SortedSet<ExchangeRate>> getMapFor(long fromCurrencyId) {
    TLongObjectMap<SortedSet<ExchangeRate>> m = rates.get(fromCurrencyId);
    if (m == null) {
        m = new TLongObjectHashMap<>();
        rates.put(fromCurrencyId, m);
    }
    return m;
}
项目:JDA    文件:EventCache.java   
public void cache(Type type, long triggerId, Runnable handler)
{
    TLongObjectMap<List<Runnable>> triggerCache =
            eventCache.computeIfAbsent(type, k -> new TLongObjectHashMap<>());

    List<Runnable> items = triggerCache.get(triggerId);
    if (items == null)
    {
        items = new LinkedList<>();
        triggerCache.put(triggerId, items);
    }

    items.add(handler);
}
项目:JDA    文件:WidgetUtil.java   
/**
 * Constructs an unavailable Widget
 */
private Widget(long guildId)
{
    isAvailable = false;
    id = guildId;
    name = null;
    invite = null;
    channels = new TLongObjectHashMap<>();
    members = new TLongObjectHashMap<>();
}
项目:CB_MAP    文件:CB_RAMTileBasedDataProcessor.java   
private CB_RAMTileBasedDataProcessor(CB_MapWriterConfiguration configuration) {
    super(configuration);
    this.nodes = new TLongObjectHashMap<>();
    this.ways = new TLongObjectHashMap<>();
    this.multipolygons = new TLongObjectHashMap<>();
    this.tileData = new CB_RAMTileData[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()][][];
    // compute number of tiles needed on each base zoom level
    for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) {
        this.tileData[i] = new CB_RAMTileData[this.tileGridLayouts[i].getAmountTilesHorizontal()][this.tileGridLayouts[i]
                .getAmountTilesVertical()];
    }
}
项目:CB_MAP    文件:CB_BaseTileBasedDataProcessor.java   
public CB_BaseTileBasedDataProcessor(CB_MapWriterConfiguration configuration) {
    super();
    this.boundingbox = configuration.getBboxConfiguration();
    this.zoomIntervalConfiguration = configuration.getZoomIntervalConfiguration();
    this.tileGridLayouts = new TileGridLayout[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()];
    this.bboxEnlargement = configuration.getBboxEnlargement();
    this.preferredLanguages = configuration.getPreferredLanguages();
    this.skipInvalidRelations = configuration.isSkipInvalidRelations();

    this.outerToInnerMapping = new TLongObjectHashMap<>();
    this.innerWaysWithoutAdditionalTags = new TLongHashSet();
    this.tilesToCoastlines = new HashMap<>();

    this.countWays = new float[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()];
    this.countWayTileFactor = new float[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()];

    this.histogramPoiTags = new TShortIntHashMap();
    this.histogramWayTags = new TShortIntHashMap();

    // compute horizontal and vertical tile coordinate offsets for all
    // base zoom levels
    for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) {
        TileCoordinate upperLeft = new TileCoordinate((int) MercatorProjection.longitudeToTileX(
                this.boundingbox.minLongitude, this.zoomIntervalConfiguration.getBaseZoom(i)),
                (int) MercatorProjection.latitudeToTileY(this.boundingbox.maxLatitude,
                        this.zoomIntervalConfiguration.getBaseZoom(i)),
                this.zoomIntervalConfiguration.getBaseZoom(i));
        this.tileGridLayouts[i] = new TileGridLayout(upperLeft, computeNumberOfHorizontalTiles(i),
                computeNumberOfVerticalTiles(i));
    }
}
项目:SRLParser    文件:FeatureVector.java   
public boolean aggregate() {

    if (size == 0) return false;

    boolean aggregated = false;

    //HashMap<Long, MatrixEntry> table = new HashMap<Long, MatrixEntry>();
    TLongObjectHashMap<Entry> table = new TLongObjectHashMap<Entry>();
    for (int i = 0; i < size; ++i) {
        int id = x[i];
        Entry item = table.get(id);
        if (item != null) {
            item.value += va[i];
            aggregated = true;
        } else
            table.put(id, new Entry(id, va[i]));
    }

    if (!aggregated) return false;

    int p = 0;
    for (Entry e : table.valueCollection()) {
        if (e.value != 0) {
            x[p] = e.x;
            va[p] = e.value;
            ++p;
        }
    }
    size = p;
    return true;
}
项目:gama    文件:GamaOsmFile.java   
public List<IShape> createSplitRoad(final Way way, final Map<String, Object> values,
        final TLongHashSet intersectionNodes, final TLongObjectHashMap<GamaShape> nodesPt) {
    final List<List<IShape>> pointsList = GamaListFactory.create(Types.LIST.of(Types.GEOMETRY));
    List<IShape> points = GamaListFactory.create(Types.GEOMETRY);
    final IList<IShape> geometries = GamaListFactory.create(Types.GEOMETRY);
    final WayNode endNode = way.getWayNodes().get(way.getWayNodes().size() - 1);
    for (final WayNode node : way.getWayNodes()) {
        final Long id = node.getNodeId();
        final GamaShape pt = nodesPt.get(id);
        if (pt == null) {
            continue;
        }
        points.add(pt);
        if (intersectionNodes.contains(id) || node == endNode) {
            if (points.size() > 1) {
                pointsList.add(points);
            }
            points = GamaListFactory.create(Types.GEOMETRY);
            points.add(pt);

        }
    }
    for (final List<IShape> pts : pointsList) {
        final IShape g = createRoad(pts, values);
        if (g != null) {
            geometries.add(g);
        }
    }
    return geometries;

}
项目:byteseek    文件:TempFileCache.java   
/**
 * Constructs a TempFileCache which creates temporary files in the directory specified.
 * If the file is null, then temporary files will be created in the default temp directory.
 *
 * @param tempDir The directory to create temporary files in.
 * @throws java.lang.IllegalArgumentException if the tempdir supplied is not a directory.
 */
public TempFileCache(final File tempDir) {
    windowPositions = new TLongObjectHashMap<WindowInfo>();
    this.tempDir = tempDir;
    if (tempDir != null && !tempDir.isDirectory()) {
        throw new IllegalArgumentException("The temp dir file supplied is not a directory: " + tempDir.getAbsolutePath());
    }
}
项目:byteseek    文件:TopAndTailStreamCache.java   
public TopAndTailStreamCache(final long topBytes, final long tailBytes) {
    this.topCacheBytes  = topBytes;
    this.tailCacheBytes = tailBytes;
    cache               = new TLongObjectHashMap<Window>();
    tailEntries         = new ArrayList<Window>();

}
项目:mapsforge    文件:BaseTileBasedDataProcessor.java   
public BaseTileBasedDataProcessor(MapWriterConfiguration configuration) {
    super();
    this.boundingbox = configuration.getBboxConfiguration();
    this.zoomIntervalConfiguration = configuration.getZoomIntervalConfiguration();
    this.tileGridLayouts = new TileGridLayout[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()];
    this.bboxEnlargement = configuration.getBboxEnlargement();
    this.preferredLanguage = configuration.getPreferredLanguage();
    this.skipInvalidRelations = configuration.isSkipInvalidRelations();

    this.outerToInnerMapping = new TLongObjectHashMap<TLongArrayList>();
    this.innerWaysWithoutAdditionalTags = new TLongHashSet();
    this.tilesToCoastlines = new HashMap<TileCoordinate, TLongHashSet>();

    this.countWays = new float[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()];
    this.countWayTileFactor = new float[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()];

    this.histogramPoiTags = new TShortIntHashMap();
    this.histogramWayTags = new TShortIntHashMap();

    // compute horizontal and vertical tile coordinate offsets for all
    // base zoom levels
    for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) {
        TileCoordinate upperLeft = new TileCoordinate((int) MercatorProjection.longitudeToTileX(
                this.boundingbox.minLongitude, this.zoomIntervalConfiguration.getBaseZoom(i)),
                (int) MercatorProjection.latitudeToTileY(this.boundingbox.maxLatitude,
                        this.zoomIntervalConfiguration.getBaseZoom(i)),
                this.zoomIntervalConfiguration.getBaseZoom(i));
        this.tileGridLayouts[i] = new TileGridLayout(upperLeft, computeNumberOfHorizontalTiles(i),
                computeNumberOfVerticalTiles(i));
    }
}
项目:mapsforge    文件:RAMTileBasedDataProcessor.java   
private RAMTileBasedDataProcessor(MapWriterConfiguration configuration) {
    super(configuration);
    this.nodes = new TLongObjectHashMap<TDNode>();
    this.ways = new TLongObjectHashMap<TDWay>();
    this.multipolygons = new TLongObjectHashMap<TDRelation>();
    this.tileData = new RAMTileData[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()][][];
    // compute number of tiles needed on each base zoom level
    for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) {
        this.tileData[i] = new RAMTileData[this.tileGridLayouts[i].getAmountTilesHorizontal()][this.tileGridLayouts[i]
                .getAmountTilesVertical()];
    }
}