本文整理汇总了Java中java.util.NavigableSet.descendingIterator方法的典型用法代码示例。如果您正苦于以下问题:Java NavigableSet.descendingIterator方法的具体用法?Java NavigableSet.descendingIterator怎么用?Java NavigableSet.descendingIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.NavigableSet
的用法示例。
在下文中一共展示了NavigableSet.descendingIterator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testKeySetDescendingIteratorOrder
import java.util.NavigableSet; //导入方法依赖的package包/类
/**
* descending iterator of key set is inverse ordered
*/
public void testKeySetDescendingIteratorOrder() {
ConcurrentSkipListMap map = map5();
NavigableSet s = map.navigableKeySet();
Iterator i = s.descendingIterator();
Integer last = (Integer)i.next();
assertEquals(last, five);
int count = 1;
while (i.hasNext()) {
Integer k = (Integer)i.next();
assertTrue(last.compareTo(k) > 0);
last = k;
++count;
}
assertEquals(5, count);
}
示例2: testDescendingKeySetDescendingIteratorOrder
import java.util.NavigableSet; //导入方法依赖的package包/类
/**
* descending iterator of descendingKeySet is ordered
*/
public void testDescendingKeySetDescendingIteratorOrder() {
ConcurrentSkipListMap map = map5();
NavigableSet s = map.descendingKeySet();
Iterator i = s.descendingIterator();
Integer last = (Integer)i.next();
assertEquals(last, one);
int count = 1;
while (i.hasNext()) {
Integer k = (Integer)i.next();
assertTrue(last.compareTo(k) < 0);
last = k;
++count;
}
assertEquals(5, count);
}
示例3: testKeySetDescendingIteratorOrder
import java.util.NavigableSet; //导入方法依赖的package包/类
/**
* descending iterator of key set is inverse ordered
*/
public void testKeySetDescendingIteratorOrder() {
TreeMap map = map5();
NavigableSet s = map.navigableKeySet();
Iterator i = s.descendingIterator();
Integer last = (Integer)i.next();
assertEquals(last, five);
int count = 1;
while (i.hasNext()) {
Integer k = (Integer)i.next();
assertTrue(last.compareTo(k) > 0);
last = k;
++count;
}
assertEquals(5, count);
}
示例4: testDescendingKeySetDescendingIteratorOrder
import java.util.NavigableSet; //导入方法依赖的package包/类
/**
* descending iterator of descendingKeySet is ordered
*/
public void testDescendingKeySetDescendingIteratorOrder() {
TreeMap map = map5();
NavigableSet s = map.descendingKeySet();
Iterator i = s.descendingIterator();
Integer last = (Integer)i.next();
assertEquals(last, one);
int count = 1;
while (i.hasNext()) {
Integer k = (Integer)i.next();
assertTrue(last.compareTo(k) < 0);
last = k;
++count;
}
assertEquals(5, count);
}
示例5: CachedRegionTracker
import java.util.NavigableSet; //导入方法依赖的package包/类
public CachedRegionTracker(Cache cache, String cacheKey, ChunkIndex chunkIndex) {
this.cache = cache;
this.cacheKey = cacheKey;
this.chunkIndex = chunkIndex;
this.regions = new TreeSet<>();
this.lookupRegion = new Region(0, 0);
synchronized (this) {
NavigableSet<CacheSpan> cacheSpans = cache.addListener(cacheKey, this);
if (cacheSpans != null) {
// Merge the spans into regions. mergeSpan is more efficient when merging from high to low,
// which is why a descending iterator is used here.
Iterator<CacheSpan> spanIterator = cacheSpans.descendingIterator();
while (spanIterator.hasNext()) {
CacheSpan span = spanIterator.next();
mergeSpan(span);
}
}
}
}
示例6: memberOfPreviousRow
import java.util.NavigableSet; //导入方法依赖的package包/类
private Member memberOfPreviousRow(NavigableSet<Cell> set,
final GetClosestRowBeforeTracker state, final Cell firstOnRow) {
NavigableSet<Cell> head = set.headSet(firstOnRow, false);
if (head.isEmpty()) return null;
for (Iterator<Cell> i = head.descendingIterator(); i.hasNext();) {
Cell found = i.next();
if (state.isExpired(found)) {
i.remove();
continue;
}
return new Member(head, found);
}
return null;
}
示例7: getContainersToPreempt
import java.util.NavigableSet; //导入方法依赖的package包/类
/**
* Based a resource preemption target drop reservations of containers and
* if necessary select containers for preemption from applications in each
* over-capacity queue. It uses {@link #NATURAL_TERMINATION_FACTOR} to
* account for containers that will naturally complete.
*
* @param queues set of leaf queues to preempt from
* @param clusterResource total amount of cluster resources
* @return a map of applciationID to set of containers to preempt
*/
private Map<ApplicationAttemptId,Set<RMContainer>> getContainersToPreempt(
List<TempQueue> queues, Resource clusterResource) {
Map<ApplicationAttemptId,Set<RMContainer>> preemptMap =
new HashMap<ApplicationAttemptId,Set<RMContainer>>();
List<RMContainer> skippedAMContainerlist = new ArrayList<RMContainer>();
for (TempQueue qT : queues) {
if (qT.preemptionDisabled && qT.leafQueue != null) {
if (LOG.isDebugEnabled()) {
if (Resources.greaterThan(rc, clusterResource,
qT.toBePreempted, Resource.newInstance(0, 0, 0))) {
LOG.debug("Tried to preempt the following "
+ "resources from non-preemptable queue: "
+ qT.queueName + " - Resources: " + qT.toBePreempted);
}
}
continue;
}
// we act only if we are violating balance by more than
// maxIgnoredOverCapacity
if (Resources.greaterThan(rc, clusterResource, qT.current,
Resources.multiply(qT.guaranteed, 1.0 + maxIgnoredOverCapacity))) {
// we introduce a dampening factor naturalTerminationFactor that
// accounts for natural termination of containers
Resource resToObtain =
Resources.multiply(qT.toBePreempted, naturalTerminationFactor);
Resource skippedAMSize = Resource.newInstance(0, 0, 0);
// lock the leafqueue while we scan applications and unreserve
synchronized (qT.leafQueue) {
NavigableSet<FiCaSchedulerApp> ns =
(NavigableSet<FiCaSchedulerApp>) qT.leafQueue.getApplications();
Iterator<FiCaSchedulerApp> desc = ns.descendingIterator();
qT.actuallyPreempted = Resources.clone(resToObtain);
while (desc.hasNext()) {
FiCaSchedulerApp fc = desc.next();
if (Resources.lessThanOrEqual(rc, clusterResource, resToObtain,
Resources.none())) {
break;
}
preemptMap.put(
fc.getApplicationAttemptId(),
preemptFrom(fc, clusterResource, resToObtain,
skippedAMContainerlist, skippedAMSize));
}
Resource maxAMCapacityForThisQueue = Resources.multiply(
Resources.multiply(clusterResource,
qT.leafQueue.getAbsoluteCapacity()),
qT.leafQueue.getMaxAMResourcePerQueuePercent());
// Can try preempting AMContainers (still saving atmost
// maxAMCapacityForThisQueue AMResource's) if more resources are
// required to be preempted from this Queue.
preemptAMContainers(clusterResource, preemptMap,
skippedAMContainerlist, resToObtain, skippedAMSize,
maxAMCapacityForThisQueue);
}
}
}
return preemptMap;
}