本文整理了Java中java.util.TreeMap.forEach()
方法的一些代码示例,展示了TreeMap.forEach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.forEach()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:forEach
暂无
代码示例来源:origin: apache/ignite
/** */
private double classify(List<LabeledVector> neighbors, Vector v, NNStrategy stgy) {
Map<Double, Double> clsVotes = new HashMap<>();
for (LabeledVector neighbor : neighbors) {
TreeMap<Double, Double> probableClsLb = ((ProbableLabel)neighbor.label()).clsLbls;
double distance = distanceMeasure.compute(v, neighbor.features());
// we predict class label, not the probability vector (it need here another math with counting of votes)
probableClsLb.forEach((label, probability) -> {
double cnt = clsVotes.containsKey(label) ? clsVotes.get(label) : 0;
clsVotes.put(label, cnt + probability * getClassVoteForVector(stgy, distance));
});
}
return getClassWithMaxVotes(clsVotes);
}
代码示例来源:origin: apache/hbase
storeFlushCtxs.forEach((name, flush) -> {
MemStoreSize snapshotSize = flush.prepare();
totalSizeOfFlushableStores.incMemStoreSize(snapshotSize);
代码示例来源:origin: pellierd/pddl4j
/**
* Returns the list of actions contained in the plan ordered depending on their time specifier.
*
* @return the ordered set of actions of the plan.
* @see Plan#actions()
*/
@Override
public final List<BitOp> actions() {
final List<BitOp> acts = new ArrayList<>();
this.actions.forEach(acts::addAll);
return acts;
}
代码示例来源:origin: SonarSource/sonarlint-core
public TelemetryAnalyzerPerformance() {
frequencies = new LinkedHashMap<>();
INTERVALS.forEach((k, v) -> frequencies.put(v, 0));
}
代码示例来源:origin: BaseXdb/basex
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("FREE SLOTS: " + free.size() + '\n');
free.forEach((key, value) ->
sb.append(" ").append(key).append(": ").append(value).append('\n'));
return sb.toString();
}
}
代码示例来源:origin: org.basex/basex
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("FREE SLOTS: " + free.size() + '\n');
free.forEach((key, value) ->
sb.append(" ").append(key).append(": ").append(value).append('\n'));
return sb.toString();
}
}
代码示例来源:origin: org.commonjava.util/partyline
/**
* Iterate all {@link FileEntry instances} to extract information about active locks.
*
* @param predicate The selector determining which files to analyze.
* @param fileConsumer The operation to extract information from a single active file.
*/
void forAll( Predicate<? super FileEntry> predicate, Consumer<FileEntry> fileConsumer )
{
TreeMap<String, FileEntry> sorted = new TreeMap<>( entryMap );
sorted.forEach( ( key, entry ) -> {
if ( entry != null && predicate.test( entry ) )
{
fileConsumer.accept( entry );
}
} );
}
代码示例来源:origin: com.qwazr/qwazr-cluster
private static TreeMap<String, ClusterServiceStatusJson.StatusEnum> toServices(
final TreeMap<String, TreeSet<String>> services) {
if (services == null || services.isEmpty())
return EMPTY;
final TreeMap<String, ClusterServiceStatusJson.StatusEnum> servicesTree = new TreeMap<>();
services.forEach(
(service, nodesSet) -> servicesTree.put(service, ClusterServiceStatusJson.StatusEnum.of(nodesSet)));
return servicesTree;
}
代码示例来源:origin: gradle.plugin.com.github.SCAREXgaming/ForgeChangelogGradlePlugin
public static TreeMap<String, String> generateLatestsFromVersions(ForgeChangelogPluginExtension ext, TreeMap<String, TreeMap<String, String>> map, TreeMap<String, String> promos) {
map.forEach((mcversion, versions) -> {
promos.put(mcversion + "-latest", versions.firstKey());
if (ext.isLatestsAsRecommended()) promos.put(mcversion + "-recommended", versions.firstKey());
});
return promos;
}
代码示例来源:origin: org.onehippo.cms/hippo-configuration-management-model
/**
* Helper for getDigest()
* @param manifest
* @return
*/
protected static String manifestToString(final TreeMap<ModuleImpl, TreeMap<String, String>> manifest) {
// print to final manifest String (with ~10k initial buffer size)
StringBuilder sb = new StringBuilder(10000);
manifest.forEach((m,items) -> {
sb.append(m.getFullName());
sb.append(":\n");
items.forEach((p,d) -> {
sb.append(" ");
sb.append(p);
sb.append(": ");
sb.append(d);
sb.append('\n');
});
});
return sb.toString();
}
代码示例来源:origin: org.commonjava.util/partyline
/**
* Render the active files as a tree structure, for output to a log file or other string-oriented output.
*/
String renderTree()
{
StringBuilder sb = new StringBuilder();
TreeMap<String, FileEntry> sorted = new TreeMap<>( entryMap );
sorted.forEach( ( key, entry ) -> {
sb.append( "+- " );
Stream.of( key.split( "/" ) ).forEach( ( part ) -> sb.append( " " ) );
sb.append( new File( key ).getName() );
if ( entry.file != null )
{
sb.append( " (F)" );
}
else
{
sb.append( "/" );
}
} );
return sb.toString();
}
代码示例来源:origin: com.qwazr/qwazr-search
protected static String[] from(final String fieldName, final Map<String, Copy> copyMap) {
if (copyMap == null || copyMap.isEmpty())
return null;
final TreeMap<Integer, List<String>> map = new TreeMap<>();
copyMap.forEach((name, copy) -> {
for (Copy.To to : copy.to())
if (fieldName.equals(to.field()))
map.computeIfAbsent(to.order(), order -> new ArrayList<>()).add(name);
});
final List<String> globalCopyFromList = new ArrayList<>();
map.forEach((order, copyFromList) -> globalCopyFromList.addAll(copyFromList));
return globalCopyFromList.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
代码示例来源:origin: com.simiacryptus/char-trie
private void reverseSubtree(TreeMap<Character, ? extends TrieNode> childrenMap, TrieNode destination) {
String suffix = new StringBuilder(destination.getRawString()).reverse().toString();
TreeMap<Character, Long> children = new TreeMap<>();
childrenMap.forEach((token, node) -> {
TrieNode analog = node.traverse(suffix);
boolean found = (token + suffix).equals(analog.getRawString());
if (found) {
children.put(token, analog.getCursorCount());
}
});
destination.writeChildren(children);
destination.getChildren().forEach(child -> reverseSubtree(childrenMap, child));
}
代码示例来源:origin: com.simiacryptus/char-trie
private void reduceSubtree(TrieNode sourceNodeA, TrieNode sourceNodeB, TrieNode destNode, BiFunction<TrieNode, TrieNode, TreeMap<Character, Long>> fn) {
destNode.writeChildren(fn.apply(sourceNodeA, sourceNodeB));
TreeMap<Character, ? extends TrieNode> sourceChildrenA = null == sourceNodeA ? null : sourceNodeA.getChildrenMap();
TreeMap<Character, ? extends TrieNode> sourceChildrenB = null == sourceNodeB ? null : sourceNodeB.getChildrenMap();
destNode.getChildrenMap().forEach((key, newChild) -> {
boolean containsA = null != sourceChildrenA && sourceChildrenA.containsKey(key);
boolean containsB = null != sourceChildrenB && sourceChildrenB.containsKey(key);
if (containsA && containsB) {
reduceSubtree(sourceChildrenA.get(key), sourceChildrenB.get(key), newChild, fn);
} else if (containsA) {
reduceSubtree(sourceChildrenA.get(key), null, newChild, fn);
} else if (containsB) {
reduceSubtree(null, sourceChildrenB.get(key), newChild, fn);
}
});
}
代码示例来源:origin: BaseXdb/basex
/**
* Lists all languages for which tokenizers and stemmers are available.
* @return supported languages
*/
public static StringList languages() {
final TreeMap<Language, Stemmer> langs = new TreeMap<>();
for(final Stemmer stem : Stemmer.IMPL) {
for(final Language l : stem.languages()) {
if(langs.containsKey(l)) continue;
for(final Tokenizer tknzr : Tokenizer.IMPL) {
if(tknzr.languages().contains(l)) langs.put(l, stem);
}
}
}
final StringList sl = new StringList();
langs.forEach((key, value) -> sl.add(key + " (" + value + ')'));
return sl.sort();
}
}
代码示例来源:origin: org.basex/basex
/**
* Lists all languages for which tokenizers and stemmers are available.
* @return supported languages
*/
public static StringList languages() {
final TreeMap<Language, Stemmer> langs = new TreeMap<>();
for(final Stemmer stem : Stemmer.IMPL) {
for(final Language l : stem.languages()) {
if(langs.containsKey(l)) continue;
for(final Tokenizer tknzr : Tokenizer.IMPL) {
if(tknzr.languages().contains(l)) langs.put(l, stem);
}
}
}
final StringList sl = new StringList();
langs.forEach((key, value) -> sl.add(key + " (" + value + ')'));
return sl.sort();
}
}
代码示例来源:origin: SoftInstigate/restheart
private CursorPool(DbsDAO dbsDAO) {
this.dbsDAO = dbsDAO;
cache = CacheFactory.createLocalCache(
POOL_SIZE,
Cache.EXPIRE_POLICY.AFTER_READ,
TTL);
collSizes = CacheFactory.createLocalLoadingCache(100,
org.restheart.cache.Cache.EXPIRE_POLICY.AFTER_WRITE,
60 * 1000,
(CursorPoolEntryKey key) -> {
return dbsDAO.getCollectionSize(
key.getCollection(),
key.getFilter());
}
);
if (LOGGER.isDebugEnabled()) {
// print stats every 1 minute
Executors.newSingleThreadScheduledExecutor()
.scheduleAtFixedRate(() -> {
getCacheSizes().forEach((s, c) -> {
LOGGER.debug("db cursor pool size: {}\t{}", s, c);
});
LOGGER.trace(""
+ "db cursor pool entries: {}",
cache.asMap().keySet());
}, 1, 1, TimeUnit.MINUTES);
}
}
代码示例来源:origin: oracle/weblogic-monitoring-exporter
private void displayMetrics(WebClient webClient, MetricsStream metricsStream, MBeanSelector selector) throws IOException {
try {
Map<String, Object> metrics = getMetrics(webClient, selector);
if (metrics != null)
sort(metrics).forEach(metricsStream::printMetric);
} catch (RestQueryException e) {
metricsStream.println("REST service was unable to handle this query\n" + selector.getPrintableRequest());
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
/**
* Displays the next menu level based on the parent menu item that was selected. Automatically pulls the key code
* and highlights it.
*
* @param p the player to show the menu to
* @param item the parent menu item to get the children of
*/
private void processKey(Player p, TARDISInfoMenu item) {
plugin.getTrackerKeeper().getInfoMenu().put(p.getUniqueId(), item);
p.sendMessage("---");
p.sendMessage("[" + item.getName() + "]");
TARDISInfoMenu.getChildren(item.toString()).forEach((key, value) -> {
String menu = key.replaceFirst(value, ChatColor.WHITE + value + ChatColor.GOLD + "");
p.sendMessage(ChatColor.GOLD + "> " + menu);
});
p.sendMessage(ChatColor.GOLD + "> " + ChatColor.WHITE + "E" + ChatColor.GOLD + "xit");
}
代码示例来源:origin: com.simiacryptus/char-trie
/**
* Write children.
*
* @param counts the counts
*/
void writeChildren(TreeMap<Character, Long> counts) {
int firstIndex = trie.nodes.length();
counts.forEach((k, v) -> {
if (v > 0) trie.nodes.add(new NodeData(k, (short) -1, -1, v, -1));
});
short length = (short) (trie.nodes.length() - firstIndex);
trie.ensureParentIndexCapacity(firstIndex, length, index);
update(n -> n.setFirstChildIndex(firstIndex).setNumberOfChildren(length));
data = null;
}
内容来源于网络,如有侵权,请联系作者删除!