當前位置: 首頁>>代碼示例>>Java>>正文


Java IntIntMap類代碼示例

本文整理匯總了Java中com.carrotsearch.hppc.IntIntMap的典型用法代碼示例。如果您正苦於以下問題:Java IntIntMap類的具體用法?Java IntIntMap怎麽用?Java IntIntMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IntIntMap類屬於com.carrotsearch.hppc包,在下文中一共展示了IntIntMap類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkIdCoverage

import com.carrotsearch.hppc.IntIntMap; //導入依賴的package包/類
void checkIdCoverage(File file) throws IOException {
    CyNetworkView view = session.getNetworkView();
    CyNetwork network = view.getModel();
    CyTable nodeTable = network.getDefaultNodeTable();

    List<String> names = SafeUtil.getStringColumnNames(nodeTable)
                                 .collect(Collectors.toList());
    CyNodeTableVisitor visitor = new CyNodeTableVisitor(nodeTable, names);

    String path = file.getPath();
    AnalyzeAnnotationConsumer consumer = new AnalyzeAnnotationConsumer() {
        @Override
        public void accept(IdMappingResult result) {
            idMappingResult = result;
            IntIntMap coverage = result.coverage;
            int topIndex = Util.getTopKey(coverage, -1);

            columnCoverage = new ObjectIntHashMap<>();
            coverage.forEach((Consumer<? super IntIntCursor>) c -> columnCoverage.addTo(names.get(c.key), c.value));

            nodeIds.setSelectedIndex(topIndex);

            try {
                String canonicalPath = file.getCanonicalPath();
                lastAnnotationPath = canonicalPath;
                notifyListeners(file);
            } catch (IOException e) {
                fail(e, "Unexpected error");
            }
        }
    };

    SimpleTaskFactory taskFactory = new SimpleTaskFactory(() -> new AnalyzeAnnotationTask(path, visitor, consumer));
    taskManager.execute(taskFactory.createTaskIterator());
}
 
開發者ID:baryshnikova-lab,項目名稱:safe-java,代碼行數:36,代碼來源:AnnotationChooserController.java

示例2: computePerColumnHitRates

import com.carrotsearch.hppc.IntIntMap; //導入依賴的package包/類
static void computePerColumnHitRates(IdMappingResult result,
                                     Set<String> nodeIds,
                                     NodeTableVisitor visitor) {

    IntIntMap columnCounts = new IntIntHashMap();

    NodeTableConsumer consumer = new NodeTableConsumer() {
        @Override
        public void startNode(int nodeId) {
            result.totalNetworkNodes++;
        }

        @Override
        public void cell(int columnId,
                         String value) {
            if (nodeIds.contains(value)) {
                columnCounts.addTo(columnId, 1);
            }
        }

        @Override
        public void endNode() {
        }
    };
    visitor.visit(consumer);

    result.coverage = columnCounts;
}
 
開發者ID:baryshnikova-lab,項目名稱:safe-java,代碼行數:29,代碼來源:IdAnalyzer.java

示例3: getTopKey

import com.carrotsearch.hppc.IntIntMap; //導入依賴的package包/類
public static int getTopKey(IntIntMap map,
                            int defaultValue) {
    int[] topKey = { defaultValue };
    int[] topCount = { 0 };
    map.forEach((Consumer<? super IntIntCursor>) c -> {
        if (c.value > topCount[0]) {
            topCount[0] = c.value;
            topKey[0] = c.key;
        }
    });
    return topKey[0];
}
 
開發者ID:baryshnikova-lab,項目名稱:safe-java,代碼行數:13,代碼來源:Util.java

示例4: applyDebugNames

import com.carrotsearch.hppc.IntIntMap; //導入依賴的package包/類
private static void applyDebugNames(Program program, PhiUpdater phiUpdater, ProgramParser parser,
        Variable[] argumentMapping) {
    if (program.basicBlockCount() == 0) {
        return;
    }

    IntIntMap[] blockEntryVariableMappings = getBlockEntryVariableMappings(program, phiUpdater, argumentMapping);

    DefinitionExtractor defExtractor = new DefinitionExtractor();
    Map<Integer, String> debugNames = new HashMap<>();
    for (int i = 0; i < program.basicBlockCount(); ++i) {
        BasicBlock block = program.basicBlockAt(i);
        IntIntMap varMap = blockEntryVariableMappings[i];
        for (Instruction insn : block) {
            insn.acceptVisitor(defExtractor);
            Map<Integer, String> newDebugNames = parser.getDebugNames(insn);
            if (newDebugNames != null) {
                debugNames = newDebugNames;
            }
            for (Variable definedVar : defExtractor.getDefinedVariables()) {
                int sourceVar = phiUpdater.getSourceVariable(definedVar.getIndex());
                if (sourceVar >= 0) {
                    varMap.put(sourceVar, definedVar.getIndex());
                }
            }
            for (Map.Entry<Integer, String> debugName : debugNames.entrySet()) {
                int receiver = varMap.getOrDefault(debugName.getKey(), -1);
                if (receiver >= 0) {
                    Variable receiverVar = program.variableAt(receiver);
                    receiverVar.setDebugName(debugName.getValue());
                    receiverVar.setLabel(debugName.getValue());
                }
            }
        }
    }
}
 
開發者ID:konsoletyper,項目名稱:teavm,代碼行數:37,代碼來源:Parser.java


注:本文中的com.carrotsearch.hppc.IntIntMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。