本文整理了Java中java.util.TreeMap.getOrDefault()
方法的一些代码示例,展示了TreeMap.getOrDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.getOrDefault()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:getOrDefault
暂无
代码示例来源:origin: apache/ignite
Double toLeftCnt = countersDistribPerCls.get(lbId).getOrDefault(bucketId, lastLeftValues.get(lbId));
代码示例来源:origin: Alluxio/alluxio
value + mSumCapacityBytesOnTierMap.getOrDefault(tier, 0L));
Map<String, String> map = mCapacityTierInfoMap.getOrDefault(tier, new HashMap<>());
map.put(workerName, FormatUtils.getSizeFromBytes(value));
mCapacityTierInfoMap.put(tier, map);
代码示例来源:origin: apache/ignite
double leftCnt = cntrDistrib.getOrDefault(bucketId, lastLeftCntrVal);
double leftY = ysDistrib.getOrDefault(bucketId, lastLeftYVal);
double leftY2 = y2sDistrib.getOrDefault(bucketId, lastLeftY2Val);
代码示例来源:origin: Rsl1122/Plan-PlayerAnalytics
private SortedMap<Long, List<T>> groupByStartOfSections(long sectionLength) {
TreeMap<Long, List<T>> map = new TreeMap<>();
if (dateHolders.isEmpty()) {
return map;
}
for (T holder : dateHolders) {
long date = holder.getDate();
long startOfMinute = date - (date % sectionLength);
List<T> list = map.getOrDefault(startOfMinute, new ArrayList<>());
list.add(holder);
map.put(startOfMinute, list);
}
return map;
}
代码示例来源:origin: Rsl1122/Plan-PlayerAnalytics
private Map<UUID, Serializable[]> getRows(TreeMap<String, Map<UUID, ? extends Serializable>> data) {
Map<UUID, Serializable[]> rows = new HashMap<>();
int size = header.length - 1;
for (PlayerContainer profile : players) {
UUID uuid = profile.getUnsafe(PlayerKeys.UUID);
Serializable[] row = new Serializable[size];
for (int i = 0; i < size; i++) {
String label = header[i + 1];
Map<UUID, ? extends Serializable> playerSpecificData = data.getOrDefault(label, new HashMap<>());
Serializable value = playerSpecificData.get(uuid);
if (value != null) {
row[i] = value;
}
}
rows.put(uuid, row);
}
return rows;
}
代码示例来源:origin: pravega/pravega
@Override
public void recordTruncationMarker(long operationSequenceNumber, LogAddress address) {
Exceptions.checkArgument(operationSequenceNumber >= 0, "operationSequenceNumber",
"Operation Sequence Number must be a positive number.");
Preconditions.checkNotNull(address, "address");
synchronized (this.truncationMarkers) {
LogAddress existing = this.truncationMarkers.getOrDefault(operationSequenceNumber, null);
if (existing == null || existing.getSequence() < address.getSequence()) {
this.truncationMarkers.put(operationSequenceNumber, address);
}
}
}
代码示例来源:origin: Rsl1122/Plan-PlayerAnalytics
public TreeMap<Long, Map<String, Set<UUID>>> toActivityDataMap(long date, long msThreshold, int loginThreshold) {
TreeMap<Long, Map<String, Set<UUID>>> activityData = new TreeMap<>();
for (long time = date; time >= date - TimeAmount.MONTH.toMillis(2L); time -= TimeAmount.WEEK.toMillis(1L)) {
Map<String, Set<UUID>> map = activityData.getOrDefault(time, new HashMap<>());
if (!players.isEmpty()) {
for (PlayerContainer player : players) {
if (player.getValue(PlayerKeys.REGISTERED).orElse(0L) > time) {
continue;
}
ActivityIndex activityIndex = player.getActivityIndex(time, msThreshold, loginThreshold);
String activityGroup = activityIndex.getGroup();
Set<UUID> uuids = map.getOrDefault(activityGroup, new HashSet<>());
uuids.add(player.getUnsafe(PlayerKeys.UUID));
map.put(activityGroup, uuids);
}
}
activityData.put(time, map);
}
return activityData;
}
代码示例来源:origin: de.datexis/texoo-core
public List<Sentence> createSentencesFromTokens(List<Token> tokens) {
List<Sentence> result = new ArrayList<>();
String text = WordHelpers.tokensToText(tokens, 0);
String lang = detectLanguage(text);
// find best Tokenizer and Splitter for text
SentenceDetectorME ssplit = sentenceSplitter.getOrDefault(lang, sentenceSplitter.get(LANG_EN));
opennlp.tools.util.Span sentences[] = ssplit.sentPosDetect(text);
// Tokenize sentences
Iterator<Token> tokenIt = tokens.iterator();
if(!tokenIt.hasNext()) return result;
Token currentToken = tokenIt.next();
for(opennlp.tools.util.Span sentence : sentences) {
if(sentence == null) continue;
List<Token> tokenList = new ArrayList<>();
while(currentToken.getBegin() < sentence.getEnd()) {
if(!currentToken.getText().equals("\n")) {
tokenList.add(currentToken);
}
if(!tokenIt.hasNext()) break;
currentToken = tokenIt.next();
}
result.add(new Sentence(tokenList));
}
return result;
}
代码示例来源:origin: Rsl1122/Plan-PlayerAnalytics
protected void activityChangeNote(TreeMap<Long, Map<String, Set<UUID>>> activityData) {
Map<String, Set<UUID>> activityNow = activityData.getOrDefault(now, new HashMap<>());
Set<UUID> veryActiveNow = activityNow.getOrDefault("Very Active", new HashSet<>());
Set<UUID> activeNow = activityNow.getOrDefault("Active", new HashSet<>());
Set<UUID> regularNow = activityNow.getOrDefault("Regular", new HashSet<>());
Map<String, Set<UUID>> activityFourWAgo = activityData.getOrDefault(monthAgo, new HashMap<>());
Set<UUID> veryActiveFWAG = activityFourWAgo.getOrDefault("Very Active", new HashSet<>());
Set<UUID> activeFWAG = activityFourWAgo.getOrDefault("Active", new HashSet<>());
代码示例来源:origin: de.datexis/texoo-core
/**
* Creates a list of Tokens from raw text (ignores sentences)
*/
public List<Token> createTokensFromText(String text, int offset) {
String language = detectLanguage(text);
TokenizerME tokenizer = plainTokenizer.getOrDefault(language, plainTokenizer.get(LANG_EN));
opennlp.tools.util.Span tokens[] = tokenizer.tokenizePos(text);
List<Token> tokenList = new LinkedList<>();
for(opennlp.tools.util.Span token : tokens) {
String tokenText = text.substring(token.getStart(), token.getEnd());
Token t = new Token(tokenText, offset + token.getStart(), offset + token.getEnd());
tokenList.add(t);
}
return tokenList;
}
代码示例来源:origin: MegaMek/megamek
heatUsed += arcHeat.getOrDefault(highArc, 0.0);
if ((adjArcCW > Integer.MIN_VALUE) && (null != arcBVs.get(adjArcCW))) {
adjArcCWBV = arcBVs.get(adjArcCW);
adjArcCWHeat = arcHeat.getOrDefault(adjArcCW, 0.0);
if ((adjArcCCW > Integer.MIN_VALUE) && (null != arcBVs.get(adjArcCCW))) {
adjArcCCWBV = arcBVs.get(adjArcCCW);
adjArcCCWHeat = arcHeat.getOrDefault(adjArcCCW, 0.0);
if ((heatUsed + arcHeat.getOrDefault(oppArc, 0.0)) > aeroHeatEfficiency) {
oppArcMult = 0.25;
bvText.append(endRow);
bvText.append(startColumn);
double totalHeat = arcHeat.getOrDefault(highArc, 0.0);
bvText.append("Total Heat: " + totalHeat);
bvText.append(endColumn);
bvText.append(startRow);
bvText.append(startColumn);
totalHeat += arcHeat.getOrDefault(adjArc, 0.0);
String over = "";
if (totalHeat > aeroHeatEfficiency) {
bvText.append(startRow);
bvText.append(startColumn);
totalHeat += arcHeat.getOrDefault(oppArc, 0.0);
String over = "";
代码示例来源:origin: CyclopsMC/IntegratedDynamics
startTime = System.nanoTime();
int lastElementTick = updateableElementsTicks.getOrDefault(element, 0);
if (canUpdate(element)) {
if (lastElementTick <= 0) {
代码示例来源:origin: de.datexis/texoo-core
TokenizerME tokenizer = newlineTokenizer.getOrDefault(lang, newlineTokenizer.get(LANG_EN));
SentenceDetectorME ssplit = sentenceSplitter.getOrDefault(lang, sentenceSplitter.get(LANG_EN));
内容来源于网络,如有侵权,请联系作者删除!