本文整理了Java中java.util.TreeMap.computeIfAbsent()
方法的一些代码示例,展示了TreeMap.computeIfAbsent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.computeIfAbsent()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:computeIfAbsent
暂无
代码示例来源:origin: OpenHFT/Chronicle-Queue
@Override
public void onNewChunk(final String filename, final int chunk, final long delayMicros) {
chunkMap.computeIfAbsent(filename, f -> new ArrayList<>()).add(chunk);
}
}
代码示例来源:origin: org.apache.spark/spark-core_2.10
long key = c.getUsed();
List<MemoryConsumer> list =
sortedConsumers.computeIfAbsent(key, k -> new ArrayList<>(1));
list.add(c);
代码示例来源:origin: org.apache.spark/spark-core
long key = c.getUsed();
List<MemoryConsumer> list =
sortedConsumers.computeIfAbsent(key, k -> new ArrayList<>(1));
list.add(c);
代码示例来源:origin: org.apache.spark/spark-core_2.11
long key = c.getUsed();
List<MemoryConsumer> list =
sortedConsumers.computeIfAbsent(key, k -> new ArrayList<>(1));
list.add(c);
代码示例来源:origin: quickfix-j/quickfixj
public List<Group> getGroups(int field) {
return groups.computeIfAbsent(field, k -> new ArrayList<>());
}
代码示例来源:origin: org.quickfixj/quickfixj-all
public List<Group> getGroups(int field) {
return groups.computeIfAbsent(field, k -> new ArrayList<>());
}
代码示例来源:origin: cc.redberry/rings
@Override
public void add(SyzygyPair<Term, Poly> sPair) {
sPairs.computeIfAbsent(weightFunction.applyAsInt(sPair), __ -> new TreeSet<>(selectionStrategy)).add(sPair);
}
代码示例来源:origin: vmware/xenon
public void addNewSearcher(IndexSearcher searcher, long creationMicros, long expirationMicros) {
PaginatedSearcherInfo info = new PaginatedSearcherInfo();
info.creationTimeMicros = creationMicros;
info.expirationTimeMicros = expirationMicros;
info.refCount = 1;
this.infoBySearcher.put(searcher, info);
this.searcherByCreationTime.put(creationMicros, searcher);
List<IndexSearcher> expirationList = this.searchersByExpirationTime
.computeIfAbsent(expirationMicros, k -> new ArrayList<>(1));
expirationList.add(searcher);
}
代码示例来源:origin: addthis/hydra
public void addTaskToQueue(int jobPriority, JobKey task, int kickPriority, boolean toHead) {
this.queueLock.lock();
try {
int totalPriority = jobPriority + kickPriority;
LinkedList<SpawnQueueItem> queue = this.mappedQueues.computeIfAbsent(totalPriority, i -> new LinkedList<>());
if (toHead) {
queue.addFirst(new SpawnQueueItem(task, kickPriority));
} else {
queue.addLast(new SpawnQueueItem(task, kickPriority));
}
} finally {
this.queueLock.unlock();
}
}
代码示例来源:origin: org.infinispan/infinispan-persistence-soft-index
void freeIndexSpace(long offset, short length) {
if (length <= 0) throw new IllegalArgumentException("Offset=" + offset + ", length=" + length);
// TODO: fragmentation!
// TODO: memory bounds!
if (offset + length < indexFileSize) {
freeBlocks.computeIfAbsent(length, k -> new ArrayList<>()).add(new IndexSpace(offset, length));
} else {
indexFileSize -= length;
try {
indexFile.truncate(indexFileSize);
} catch (IOException e) {
log.cannotTruncateIndex(e);
}
}
}
代码示例来源: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: io.permazen/permazen-coreapi
/**
* Add a pending notification for any {@link FieldMonitor}s watching the specified field in the specified object.
* This method assumes only the appropriate type of monitor is registered as a listener on the field
* and that the provided old and new values have the appropriate types.
*
* <p>
* This method should only be invoked if this.disableListenerNotifications is false.
*/
void addFieldChangeNotification(FieldChangeNotifier<?> notifier) {
assert Thread.holdsLock(this);
assert !this.disableListenerNotifications;
// Get info
final ObjId id = notifier.getId();
final int fieldStorageId = notifier.getStorageId();
// Does anybody care?
if (!this.hasFieldMonitor(id, fieldStorageId))
return;
// Add a pending field monitor notification for the specified field
this.pendingNotifications.get().computeIfAbsent(fieldStorageId, i -> new ArrayList<>(2)).add(notifier);
}
代码示例来源:origin: Qihoo360/Quicksql
/**
* Handles adding a command to {@link #threadMap}.
*
* @return the newly-added command
*/
protected ConcurrentTestCommand addCommand(
int threadId,
int order,
ConcurrentTestCommand command) {
assert threadId > 0;
assert order > 0;
TreeMap<Integer, ConcurrentTestCommand> commandMap =
threadMap.computeIfAbsent(threadId, k -> new TreeMap<>());
// check for duplicate order numbers
assert !commandMap.containsKey(order);
commandMap.put(order, command);
return command;
}
代码示例来源:origin: org.basex/basex
/**
* Adds a value for the specified slot size.
* @param size byte size
* @param offset file offset
* @param opt optimize
*/
private void add(final int size, final long offset, final boolean opt) {
free.computeIfAbsent(size, k -> new LongList()).add(offset);
slots++;
if(opt) optimize();
}
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Handles adding a command to {@link #threadMap}.
*
* @return the newly-added command
*/
protected ConcurrentTestCommand addCommand(
int threadId,
int order,
ConcurrentTestCommand command) {
assert threadId > 0;
assert order > 0;
TreeMap<Integer, ConcurrentTestCommand> commandMap =
threadMap.computeIfAbsent(threadId, k -> new TreeMap<>());
// check for duplicate order numbers
assert !commandMap.containsKey(order);
commandMap.put(order, command);
return command;
}
代码示例来源:origin: apache/roller
/**
* @inheritDoc
*/
public Map<Date, List<WeblogEntry>> getWeblogEntryObjectMap(WeblogEntrySearchCriteria wesc) throws WebloggerException {
TreeMap<Date, List<WeblogEntry>> map = new TreeMap<>(Collections.reverseOrder());
List<WeblogEntry> entries = getWeblogEntries(wesc);
Calendar cal = Calendar.getInstance();
if (wesc.getWeblog() != null) {
cal.setTimeZone(wesc.getWeblog().getTimeZoneInstance());
}
for (WeblogEntry entry : entries) {
Date sDate = DateUtil.getNoonOfDay(entry.getPubTime(), cal);
List<WeblogEntry> dayEntries = map.computeIfAbsent(sDate, k -> new ArrayList<>());
dayEntries.add(entry);
}
return map;
}
代码示例来源:origin: BaseXdb/basex
/**
* Adds a value for the specified slot size.
* @param size byte size
* @param offset file offset
* @param opt optimize
*/
private void add(final int size, final long offset, final boolean opt) {
free.computeIfAbsent(size, k -> new LongList()).add(offset);
slots++;
if(opt) optimize();
}
代码示例来源:origin: org.apache.lens/lens-cube
/**
* helper method for ensuring get(storageTable).get(updatePeriod).get(partitionColumn) gives a non-null object.
* <p></p>
* kind of like mkdir -p
*
* @param timeLineKey storage table
* @param updatePeriod update period
* @param partitionColumn partition column
* @return timeline if already exists, or puts a new timeline and returns.
*/
public PartitionTimeline ensureEntry(String timeLineKey, String storagTableName, UpdatePeriod updatePeriod,
String partitionColumn) {
return this
.computeIfAbsent(timeLineKey, s -> new TreeMap<>())
.computeIfAbsent(updatePeriod, k -> new CaseInsensitiveStringHashMap<>())
.computeIfAbsent(partitionColumn, c -> PartitionTimelineFactory.get(
CubeMetastoreClient.this, storagTableName, updatePeriod, c));
}
代码示例来源:origin: apache/lens
/**
* helper method for ensuring get(storageTable).get(updatePeriod).get(partitionColumn) gives a non-null object.
* <p></p>
* kind of like mkdir -p
*
* @param timeLineKey storage table
* @param updatePeriod update period
* @param partitionColumn partition column
* @return timeline if already exists, or puts a new timeline and returns.
*/
public PartitionTimeline ensureEntry(String timeLineKey, String storagTableName, UpdatePeriod updatePeriod,
String partitionColumn) {
return this
.computeIfAbsent(timeLineKey, s -> new TreeMap<>())
.computeIfAbsent(updatePeriod, k -> new CaseInsensitiveStringHashMap<>())
.computeIfAbsent(partitionColumn, c -> PartitionTimelineFactory.get(
CubeMetastoreClient.this, storagTableName, updatePeriod, c));
}
代码示例来源:origin: hneemann/Digital
private void addProdFor(String name, Expression e) throws FuseMapFillerException {
ProdInput pt = new ProdInput(getInputCount());
if (e instanceof Operation.And) {
Operation.And and = (Operation.And) e;
for (Expression z : and.getExpressions())
pt.add(z);
} else
pt.add(e);
StateSet o = termMap.computeIfAbsent(pt, k -> new StateSet(getOutputCount()));
o.set(getOutNum(name));
}
内容来源于网络,如有侵权,请联系作者删除!