本文整理了Java中java.util.TreeMap.tailMap()
方法的一些代码示例,展示了TreeMap.tailMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.tailMap()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:tailMap
暂无
代码示例来源:origin: commons-collections/commons-collections
/**
* Return a view of the portion of this map whose keys are greater than
* or equal to the specified key.
*
* @param key Key less than or equal to any in the returned map
* @return a tail map
*/
public SortedMap tailMap(Object key) {
if (fast) {
return (map.tailMap(key));
} else {
synchronized (map) {
return (map.tailMap(key));
}
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Finds smallest t' > t where q(t')!=q(t)
*
* If there's no such t' this method returns null.
*/
private Long next(long t) {
SortedMap<Long, int[]> x = data.tailMap(t + 1);
return x.isEmpty() ? null : x.firstKey();
}
代码示例来源:origin: wildfly/wildfly
/**
* Return a view of the portion of this map whose keys are greater than
* or equal to the specified key.
*
* @param key Key less than or equal to any in the returned map
* @return a tail map
*/
public SortedMap tailMap(Object key) {
if (fast) {
return (map.tailMap(key));
} else {
synchronized (map) {
return (map.tailMap(key));
}
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* increases q(t) by n for t in [start,end).
*
* @return peak value of q(t) in this range as a result of addition.
*/
int insert(long start, long end, int n) {
splitAt(start);
splitAt(end);
int peak = 0;
for (Map.Entry<Long, int[]> e : data.tailMap(start).headMap(end).entrySet()) {
peak = max(peak, e.getValue()[0] += n);
}
return peak;
}
代码示例来源: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: 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: 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: atomix/atomix
@Override
public void truncate(long index) {
positions.tailMap(index, false).clear();
}
}
代码示例来源: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: goldmansachs/gs-collections
public MutableSortedMap<K, V> tailMap(K fromKey)
{
return SortedMapAdapter.adapt(this.treeMap.tailMap(fromKey));
}
代码示例来源:origin: eclipse/eclipse-collections
@Override
public MutableSortedMap<K, V> tailMap(K fromKey)
{
return SortedMapAdapter.adapt(this.treeMap.tailMap(fromKey));
}
代码示例来源:origin: eclipse/eclipse-collections
@Override
public MutableSortedMap<K, V> tailMap(K fromKey)
{
return SortedMapAdapter.adapt(this.treeMap.tailMap(fromKey));
}
代码示例来源:origin: com.h2database/h2
@Override
public List<FilePath> newDirectoryStream() {
ArrayList<FilePath> list = New.arrayList();
synchronized (MEMORY_FILES) {
for (String n : MEMORY_FILES.tailMap(name).keySet()) {
if (n.startsWith(name)) {
if (!n.equals(name) && n.indexOf('/', name.length() + 1) < 0) {
list.add(getPath(n));
}
} else {
break;
}
}
return list;
}
}
代码示例来源:origin: com.h2database/h2
@Override
public List<FilePath> newDirectoryStream() {
ArrayList<FilePath> list = New.arrayList();
synchronized (MEMORY_FILES) {
for (String n : MEMORY_FILES.tailMap(name).keySet()) {
if (n.startsWith(name)) {
list.add(getPath(n));
} else {
break;
}
}
return list;
}
}
代码示例来源:origin: apache/storm
@Override
public void fail(Object msgId) {
TransactionAttempt tx = (TransactionAttempt) msgId;
TransactionStatus stored = _activeTx.remove(tx.getTransactionId());
LOG.debug("Fail. [tx_attempt = {}], [tx_status = {}], [{}]", tx, stored, this);
if (stored != null && tx.equals(stored.attempt)) {
_activeTx.tailMap(tx.getTransactionId()).clear();
sync();
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public synchronized void fail(Object msgId) {
TransactionAttempt tx = (TransactionAttempt) msgId;
TransactionStatus stored = _activeTx.remove(tx.getTransactionId());
if (stored != null && tx.equals(stored.attempt)) {
_activeTx.tailMap(tx.getTransactionId()).clear();
sync();
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public synchronized void fail(Object msgId) {
TransactionAttempt tx = (TransactionAttempt) msgId;
TransactionStatus stored = _activeTx.remove(tx.getTransactionId());
if (stored != null && tx.equals(stored.attempt)) {
_activeTx.tailMap(tx.getTransactionId()).clear();
sync();
}
}
代码示例来源:origin: alibaba/mdrill
@Override
public void fail(Object msgId) {
TransactionAttempt tx = (TransactionAttempt) msgId;
TransactionStatus stored = _activeTx.remove(tx.getTransactionId());
if(stored!=null && tx.equals(stored.attempt)) {
_activeTx.tailMap(tx.getTransactionId()).clear();
sync();
}
}
内容来源于网络,如有侵权,请联系作者删除!