java.util.TreeMap.lastKey()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中java.util.TreeMap.lastKey()方法的一些代码示例,展示了TreeMap.lastKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.lastKey()方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:lastKey

TreeMap.lastKey介绍

暂无

代码示例

代码示例来源:origin: commons-collections/commons-collections

/**
 * Return the last (highest) key currently in this sorted map.
 * 
 * @return the last key in the map
 */
public Object lastKey() {
  if (fast) {
    return (map.lastKey());
  } else {
    synchronized (map) {
      return (map.lastKey());
    }
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * Return the last (highest) key currently in this sorted map.
 * 
 * @return the last key in the map
 */
public Object lastKey() {
  if (fast) {
    return (map.lastKey());
  } else {
    synchronized (map) {
      return (map.lastKey());
    }
  }
}

代码示例来源:origin: goldmansachs/gs-collections

public K lastKey()
{
  return this.treeMap.lastKey();
}

代码示例来源:origin: eclipse/eclipse-collections

@Override
public K lastKey()
{
  return this.treeMap.lastKey();
}

代码示例来源:origin: eclipse/eclipse-collections

@Override
public K lastKey()
{
  return this.treeMap.lastKey();
}

代码示例来源:origin: apache/hive

public int removeBiggest() {
 Integer last = indexes.lastKey();
 indexes.remove(last);
 return last;
}

代码示例来源:origin: apache/drill

public int removeBiggest() {
 Integer last = indexes.lastKey();
 indexes.remove(last);
 return last;
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * Gets the last row on the sheet
 *
 * @return last row contained n this sheet (0-based)
 */
@Override
public int getLastRowNum()
{
  return _rows.size() == 0 ? 0 : _rows.lastKey();
}

代码示例来源: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: kevin-wayne/algs4

/**
 * Returns the largest key in this symbol table.
 *
 * @return the largest key in this symbol table
 * @throws NoSuchElementException if this symbol table is empty
 */
public Key max() {
  if (isEmpty()) throw new NoSuchElementException("calls max() with empty symbol table");
  return st.lastKey();
}

代码示例来源:origin: looly/hutool

/**
 * 下一个随机对象
 * 
 * @return 随机对象
 */
public T next() {
  if(MapUtil.isEmpty(this.weightMap)) {
    return null;
  }
  final double randomWeight = this.weightMap.lastKey() * random.nextDouble();
  final SortedMap<Double, T> tailMap = this.weightMap.tailMap(randomWeight, false);
  return this.weightMap.get(tailMap.firstKey());
}

代码示例来源:origin: looly/hutool

/**
 * 下一个随机对象
 * 
 * @return 随机对象
 */
public T next() {
  if(MapUtil.isEmpty(this.weightMap)) {
    return null;
  }
  final double randomWeight = this.weightMap.lastKey() * random.nextDouble();
  final SortedMap<Double, T> tailMap = this.weightMap.tailMap(randomWeight, false);
  return this.weightMap.get(tailMap.firstKey());
}

代码示例来源:origin: apache/kylin

void updateOnBufferChange() {
  if (aggBufMap.size() > aggregateBufferSizeLimit) {
    aggBufMap.pollLastEntry();
    Preconditions.checkState(aggBufMap.size() == aggregateBufferSizeLimit);
  }
  currentLastKey = aggBufMap.lastKey();
}

代码示例来源:origin: apache/kylin

long getMaxKey() {
  return getKetamaNodes().lastKey();
}

代码示例来源:origin: igniterealtime/Smack

public int loadCurrentOmemoSignedPreKeyId(OmemoDevice userDevice) {
  return loadOmemoSignedPreKeys(userDevice).lastKey();
}

代码示例来源:origin: apache/rocketmq

public long commit() {
  try {
    this.lockTreeMap.writeLock().lockInterruptibly();
    try {
      Long offset = this.consumingMsgOrderlyTreeMap.lastKey();
      msgCount.addAndGet(0 - this.consumingMsgOrderlyTreeMap.size());
      for (MessageExt msg : this.consumingMsgOrderlyTreeMap.values()) {
        msgSize.addAndGet(0 - msg.getBody().length);
      }
      this.consumingMsgOrderlyTreeMap.clear();
      if (offset != null) {
        return offset + 1;
      }
    } finally {
      this.lockTreeMap.writeLock().unlock();
    }
  } catch (InterruptedException e) {
    log.error("commit exception", e);
  }
  return -1;
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
public void add( String fileName, FileStream fileWriterOutputStream ) {
 long index = 0;
 if ( size() > 0 ) {
  index = indexMap.lastKey() + 1;
 }
 FileStreamsCollectionEntry newEntry = new FileStreamsCollectionEntry( fileName, index, fileWriterOutputStream );
 fileNameMap.put( fileName, newEntry );
 indexMap.put( index, newEntry );
 if ( fileWriterOutputStream.isOpen() ) {
  numOpenFiles++;
 }
}

代码示例来源:origin: looly/hutool

/**
 * 增加对象权重
 * 
 * @param weightObj 权重对象
 * @return this
 */
public WeightRandom<T> add(WeightObj<T> weightObj) {
  if(null != weightObj) {
    final double weight = weightObj.getWeight();
    if(weightObj.getWeight() > 0) {
      double lastWeight = (this.weightMap.size() == 0) ? 0 : this.weightMap.lastKey();
      this.weightMap.put(weight + lastWeight, weightObj.getObj());// 权重累加
    }
  }
  return this;
}

代码示例来源:origin: looly/hutool

/**
 * 增加对象权重
 * 
 * @param weightObj 权重对象
 * @return this
 */
public WeightRandom<T> add(WeightObj<T> weightObj) {
  if(null != weightObj) {
    final double weight = weightObj.getWeight();
    if(weightObj.getWeight() > 0) {
      double lastWeight = (this.weightMap.size() == 0) ? 0 : this.weightMap.lastKey();
      this.weightMap.put(weight + lastWeight, weightObj.getObj());// 权重累加
    }
  }
  return this;
}

代码示例来源: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();
  }
}

相关文章

微信公众号

最新文章

更多