本文整理了Java中java.util.TreeMap.compute()
方法的一些代码示例,展示了TreeMap.compute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.compute()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:compute
[英]Find the level down to which to assign all nodes BLACK. This is the last full' level of the complete binary tree produced by buildTree. The remaining nodes are colored RED. (This makes a
nice' set of color assignments wrt future insertions.) This level number is computed by finding the number of splits needed to reach the zeroeth node. (The answer is ~lg(N), but in any case must be computed by same quick O(lg(N)) loop.)
[中]查找要将所有节点指定为黑色的级别。这是buildTree生成的完整二叉树的最后一个“完整”级别。其余节点的颜色为红色。(这将为将来的插入创建一组“漂亮”的颜色指定。)通过查找到达zeroeth节点所需的拆分数来计算此级别数。(答案是~lg(N),但在任何情况下都必须由相同的快速O(lg(N))循环计算。)
代码示例来源:origin: nlpie/biomedicus
public Builder addIdentifier(int identifier) {
identifierToCount.compute(identifier, (id, count) -> {
if (count == null) {
count = 0;
}
return count + 1;
});
return this;
}
代码示例来源:origin: opencb/opencga
private void addVariant(Variant variant, String chromosome, long slicePos) {
List<Variant> list;
TreeMap<Long, List<Variant>> positionMap = bufferTree.compute(chromosome,
(s, map) -> map == null ? new TreeMap<>(Long::compareTo) : map);
list = positionMap.compute(slicePos, (pos, variants) -> variants == null ? new LinkedList<>() : variants);
if (list.isEmpty()) {
// New list, new slice
numSlices++;
}
list.add(variant);
if (currentChromosome == null) {
// Set first chromosome
currentChromosome = chromosome;
}
}
代码示例来源:origin: BaseXdb/basex
/**
* Adds a package to the specified map.
* @param pkg package
* @param map map
*/
private static void add(final Pkg pkg, final TreeMap<String, Pkg> map) {
map.compute(pkg.id(), (k, v) -> v == null ? pkg : v.merge(pkg));
}
代码示例来源:origin: org.basex/basex
/**
* Adds a package to the specified map.
* @param pkg package
* @param map map
*/
private static void add(final Pkg pkg, final TreeMap<String, Pkg> map) {
map.compute(pkg.id(), (k, v) -> v == null ? pkg : v.merge(pkg));
}
内容来源于网络,如有侵权,请联系作者删除!