本文整理了Java中java.util.TreeMap.firstEntry()
方法的一些代码示例,展示了TreeMap.firstEntry()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.firstEntry()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:firstEntry
暂无
代码示例来源:origin: apache/incubator-dubbo
private Invoker<T> selectForKey(long hash) {
Map.Entry<Long, Invoker<T>> entry = virtualInvokers.ceilingEntry(hash);
if (entry == null) {
entry = virtualInvokers.firstEntry();
}
return entry.getValue();
}
代码示例来源:origin: apache/incubator-dubbo
private Invoker<T> selectForKey(long hash) {
Map.Entry<Long, Invoker<T>> entry = virtualInvokers.ceilingEntry(hash);
if (entry == null) {
entry = virtualInvokers.firstEntry();
}
return entry.getValue();
}
代码示例来源:origin: stackoverflow.com
TreeMap<String, String> myMap = new TreeMap<String, String>();
String first = myMap.firstEntry().getValue();
String firstOther = myMap.get(myMap.firstKey());
代码示例来源:origin: graphhopper/graphhopper
public int peekValue() {
if (size == 0) {
throw new IllegalStateException("collection is already empty!?");
}
Entry<Integer, GHIntHashSet> e = map.firstEntry();
if (e.getValue().isEmpty()) {
throw new IllegalStateException("internal set is already empty!?");
}
return map.firstEntry().getKey();
}
代码示例来源:origin: alibaba/jstorm
protected Entry<Integer, ColumnFamilyHandle> getHandler(int timeoutSecond) {
Entry<Integer, ColumnFamilyHandle> ceilingEntry = windowHandlers.ceilingEntry(timeoutSecond);
if (ceilingEntry != null) {
return ceilingEntry;
} else {
return windowHandlers.firstEntry();
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public void put(String key, Object value) {
put(key, value, windowHandlers.firstEntry());
}
代码示例来源:origin: alibaba/jstorm
@Override
public void putBatch(Map<String, Object> map) {
putBatch(map, windowHandlers.firstEntry());
}
代码示例来源:origin: alipay/sofa-rpc
/**
* Select for key.
*
* @param hash the hash
* @return the provider
*/
private ProviderInfo selectForKey(long hash) {
Map.Entry<Long, ProviderInfo> entry = virtualNodes.ceilingEntry(hash);
if (entry == null) {
entry = virtualNodes.firstEntry();
}
return entry.getValue();
}
代码示例来源:origin: apache/hbase
public long getActiveMinProcId() {
Map.Entry<Long, BitSetNode> entry = map.firstEntry();
return entry == null ? Procedure.NO_PROC_ID : entry.getValue().getActiveMinProcId();
}
代码示例来源:origin: graphhopper/graphhopper
public float peekValue() {
long key = map.firstEntry().getKey();
return Float.intBitsToFloat(bitUtil.getIntHigh(key));
}
代码示例来源:origin: graphhopper/graphhopper
public int peekKey() {
long key = map.firstEntry().getKey();
return bitUtil.getIntLow(key);
}
代码示例来源:origin: alipay/sofa-rpc
/**
* Select for key.
*
* @param hash the hash
* @return the provider
*/
private ProviderInfo selectForKey(long hash) {
Map.Entry<Long, ProviderInfo> entry = virtualNodes.ceilingEntry(hash);
if (entry == null) {
entry = virtualNodes.firstEntry();
}
return entry.getValue();
}
代码示例来源:origin: alipay/sofa-rpc
/**
* Select for key.
*
* @param hash the hash
* @return the provider
*/
private ProviderInfo selectForKey(long hash) {
Map.Entry<Long, ProviderInfo> entry = virtualNodes.ceilingEntry(hash);
if (entry == null) {
entry = virtualNodes.firstEntry();
}
return entry.getValue();
}
代码示例来源:origin: alipay/sofa-rpc
/**
* Select for key.
*
* @param hash the hash
* @return the provider
*/
private ProviderInfo selectForKey(long hash) {
Map.Entry<Long, ProviderInfo> entry = virtualNodes.ceilingEntry(hash);
if (entry == null) {
entry = virtualNodes.firstEntry();
}
return entry.getValue();
}
代码示例来源:origin: xuxueli/xxl-job
public String hashJob(int jobId, List<String> addressList) {
// ------A1------A2-------A3------
// -----------J1------------------
TreeMap<Long, String> addressRing = new TreeMap<Long, String>();
for (String address: addressList) {
for (int i = 0; i < VIRTUAL_NODE_NUM; i++) {
long addressHash = hash("SHARD-" + address + "-NODE-" + i);
addressRing.put(addressHash, address);
}
}
long jobHash = hash(String.valueOf(jobId));
SortedMap<Long, String> lastRing = addressRing.tailMap(jobHash);
if (!lastRing.isEmpty()) {
return lastRing.get(lastRing.firstKey());
}
return addressRing.firstEntry().getValue();
}
代码示例来源:origin: graphhopper/graphhopper
public int peekKey() {
if (size == 0) {
throw new IllegalStateException("collection is already empty!?");
}
GHIntHashSet set = map.firstEntry().getValue();
if (set.isEmpty()) {
throw new IllegalStateException("internal set is already empty!?");
}
return set.iterator().next().value;
}
代码示例来源:origin: apache/rocketmq
@Override
public void reportConsumerRunningInfo(TreeMap<String, ConsumerRunningInfo> criTable) {
{
boolean result = ConsumerRunningInfo.analyzeSubscription(criTable);
if (!result) {
log.info(String.format(LOG_NOTIFY
+ "reportConsumerRunningInfo: ConsumerGroup: %s, Subscription different", criTable
.firstEntry().getValue().getProperties().getProperty("consumerGroup")));
}
}
{
Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator();
while (it.hasNext()) {
Entry<String, ConsumerRunningInfo> next = it.next();
String result = ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
if (!result.isEmpty()) {
log.info(String.format(LOG_NOTIFY
+ "reportConsumerRunningInfo: ConsumerGroup: %s, ClientId: %s, %s",
criTable.firstEntry().getValue().getProperties().getProperty("consumerGroup"),
next.getKey(),
result));
}
}
}
}
代码示例来源:origin: prestodb/presto
return;
Entry<String, Type> first = fieldsMap.firstEntry();
String field = first.getKey();
Type type = first.getValue();
代码示例来源:origin: pxb1988/dex2jar
public static BaseDexFileReader open(byte[] data) throws IOException {
if (data.length < 3) {
throw new IOException("File too small to be a dex/zip");
}
if ("dex".equals(new String(data, 0, 3, StandardCharsets.ISO_8859_1))) {// dex
return new DexFileReader(data);
} else if ("PK".equals(new String(data, 0, 2, StandardCharsets.ISO_8859_1))) {// ZIP
TreeMap<String, DexFileReader> dexFileReaders = new TreeMap<>();
try (ZipFile zipFile = new ZipFile(data)) {
for (ZipEntry e : zipFile.entries()) {
String entryName = e.getName();
if (entryName.startsWith("classes") && entryName.endsWith(".dex")) {
if (!dexFileReaders.containsKey(entryName)) { // only the first one
dexFileReaders.put(entryName, new DexFileReader(toByteArray(zipFile.getInputStream(e))));
}
}
}
}
if (dexFileReaders.size() == 0) {
throw new IOException("Can not find classes.dex in zip file");
} else if (dexFileReaders.size() == 1) {
return dexFileReaders.firstEntry().getValue();
} else {
return new MultiDexFileReader(dexFileReaders.values());
}
}
throw new IOException("the src file not a .dex or zip file");
}
代码示例来源:origin: apache/kafka
@Override
public synchronized void tick() {
long timeMs = time.milliseconds();
while (true) {
Map.Entry<Long, List<KafkaFutureImpl<Long>>> entry = waiters.firstEntry();
if ((entry == null) || (entry.getKey() > timeMs)) {
break;
}
for (KafkaFutureImpl<Long> future : entry.getValue()) {
future.complete(timeMs);
}
waiters.remove(entry.getKey());
}
}
内容来源于网络,如有侵权,请联系作者删除!