本文整理了Java中java.util.TreeMap.firstKey()
方法的一些代码示例,展示了TreeMap.firstKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.firstKey()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:firstKey
暂无
代码示例来源:origin: commons-collections/commons-collections
/**
* Return the first (lowest) key currently in this sorted map.
*
* @return the first key in the map
*/
public Object firstKey() {
if (fast) {
return (map.firstKey());
} else {
synchronized (map) {
return (map.firstKey());
}
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Return the first (lowest) key currently in this sorted map.
*
* @return the first key in the map
*/
public Object firstKey() {
if (fast) {
return (map.firstKey());
} else {
synchronized (map) {
return (map.firstKey());
}
}
}
代码示例来源:origin: goldmansachs/gs-collections
public K firstKey()
{
return this.treeMap.firstKey();
}
代码示例来源:origin: eclipse/eclipse-collections
@Override
public K firstKey()
{
return this.treeMap.firstKey();
}
代码示例来源:origin: eclipse/eclipse-collections
@Override
public K firstKey()
{
return this.treeMap.firstKey();
}
代码示例来源:origin: apache/ignite
/** */
private Long activeMinimal() {
Long min = null;
for (TreeMap<Long, AtomicInteger> s : activeQueries.values()) {
Long first = s.firstKey();
if (min == null || first < min)
min = first;
}
return min;
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Get the 0-based number of the first cell contained in this row.
*
* @return short representing the first logical cell in the row,
* or -1 if the row does not contain any cells.
*/
@Override
public short getFirstCellNum() {
return (short)(_cells.size() == 0 ? -1 : _cells.firstKey());
}
代码示例来源:origin: linkedin/parseq
private void trimStalls(long oldestTimestamp) {
while (!_stalls.isEmpty() && _stalls.firstKey() < oldestTimestamp) {
_stalls.remove(_stalls.firstKey());
}
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public E next() {
count++;
return values.remove(currentElements.remove(currentElements.firstKey()));
}
代码示例来源:origin: stackoverflow.com
TreeMap<String, String> myMap = new TreeMap<String, String>();
String first = myMap.firstEntry().getValue();
String firstOther = myMap.get(myMap.firstKey());
代码示例来源:origin: Alluxio/alluxio
/**
* Print the time series sparsely, i.e. it ignores buckets with 0 events.
*
* @param stream the print stream
*/
public void sparsePrint(PrintStream stream) {
if (mSeries.isEmpty()) {
return;
}
long start = mSeries.firstKey();
stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);
for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) {
stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue());
}
}
代码示例来源:origin: kevin-wayne/algs4
/**
* Returns the smallest key in this symbol table.
*
* @return the smallest key in this symbol table
* @throws NoSuchElementException if this symbol table is empty
*/
public Key min() {
if (isEmpty()) throw new NoSuchElementException("calls min() with empty symbol table");
return st.firstKey();
}
代码示例来源:origin: sohutv/cachecloud
public S getShardInfo(byte[] key) {
SortedMap<Long, S> tail = nodes.tailMap(algo.hash(key));
if (tail.isEmpty()) {
return nodes.get(nodes.firstKey());
}
return tail.get(tail.firstKey());
}
代码示例来源:origin: apache/rocketmq
public long getMaxSpan() {
try {
this.lockTreeMap.readLock().lockInterruptibly();
try {
if (!this.msgTreeMap.isEmpty()) {
return this.msgTreeMap.lastKey() - this.msgTreeMap.firstKey();
}
} finally {
this.lockTreeMap.readLock().unlock();
}
} catch (InterruptedException e) {
log.error("getMaxSpan exception", e);
}
return 0;
}
代码示例来源:origin: apache/kylin
public long estimatedMemSize() {
if (aggBufMap.isEmpty())
return 0;
byte[] sampleKey = aggBufMap.firstKey();
MeasureAggregator<?>[] sampleValue = aggBufMap.get(sampleKey);
return estimateSizeOfAggrCache(sampleKey, sampleValue, aggBufMap.size());
}
代码示例来源:origin: FudanNLP/fnlp
private int[] minIdMap() {
double key = sortmap.firstKey();
Set<String> set = sortmap.get(key);
Iterator<String> it = set.iterator();
int[] id = string2Id(it.next());
// System.out.println(key + " " + id[0] + " " + id[1]);
return id;
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public S selectForKey(String key) {
SortedMap<Long, S> tail = nodes.tailMap(hash(key)); // 沿环的顺时针找到一个虚拟节点
if (tail.size() == 0) {
return nodes.get(nodes.firstKey());
}
return tail.get(tail.firstKey()); // 返回该虚拟节点对应的真实机器节点的信息
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public S selectForKey(String key) {
SortedMap<Long, S> tail = nodes.tailMap(hash(key)); // 沿环的顺时针找到一个虚拟节点
if (tail.size() == 0) {
return nodes.get(nodes.firstKey());
}
return tail.get(tail.firstKey()); // 返回该虚拟节点对应的真实机器节点的信息
}
代码示例来源:origin: apache/rocketmq
public void fillProcessQueueInfo(final ProcessQueueInfo info) {
try {
this.lockTreeMap.readLock().lockInterruptibly();
if (!this.msgTreeMap.isEmpty()) {
info.setCachedMsgMinOffset(this.msgTreeMap.firstKey());
info.setCachedMsgMaxOffset(this.msgTreeMap.lastKey());
info.setCachedMsgCount(this.msgTreeMap.size());
info.setCachedMsgSizeInMiB((int) (this.msgSize.get() / (1024 * 1024)));
}
if (!this.consumingMsgOrderlyTreeMap.isEmpty()) {
info.setTransactionMsgMinOffset(this.consumingMsgOrderlyTreeMap.firstKey());
info.setTransactionMsgMaxOffset(this.consumingMsgOrderlyTreeMap.lastKey());
info.setTransactionMsgCount(this.consumingMsgOrderlyTreeMap.size());
}
info.setLocked(this.locked);
info.setTryUnlockTimes(this.tryUnlockTimes.get());
info.setLastLockTimestamp(this.lastLockTimestamp);
info.setDroped(this.dropped);
info.setLastPullTimestamp(this.lastPullTimestamp);
info.setLastConsumeTimestamp(this.lastConsumeTimestamp);
} catch (Exception e) {
} finally {
this.lockTreeMap.readLock().unlock();
}
}
代码示例来源:origin: igniterealtime/Smack
@Test
public void generateOmemoPreKeysIdsMatchAndNoNullValues() {
TreeMap<Integer, T_PreKey> pks =
keyUtil.generateOmemoPreKeys(1, 20);
for (int i = 1; i <= 20; i++) {
assertEquals("PreKeyIds must correspond the requested ids.", Integer.valueOf(i), pks.firstKey());
assertNotNull("All PreKeys must not be null.", pks.get(pks.firstKey()));
pks.remove(pks.firstKey());
}
}
内容来源于网络,如有侵权,请联系作者删除!