当前位置: 首页>>代码示例>>Java>>正文


Java Deque.getLast方法代码示例

本文整理汇总了Java中java.util.Deque.getLast方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.getLast方法的具体用法?Java Deque.getLast怎么用?Java Deque.getLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Deque的用法示例。


在下文中一共展示了Deque.getLast方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toStyleProcessor

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Return the style corresponding to the threshold value.
 */
protected Processor<SlaData> toStyleProcessor(final JiraSlaComputations slaComputations, final String styleNormal,
		final String styleOver) {
	return new Processor<SlaData>() {
		@Override
		public Object getValue(final Deque<Object> contextData) {
			// Get the context
			final Object[] context = contextData.toArray();
			final SlaData data = (SlaData) contextData.getLast();
			final int index = (Integer) context[context.length - 2];
			final long threshold = slaComputations.getSlaConfigurations().get(index).getThreshold();

			// Check the threshold
			if (data != null && threshold != 0 && data.getDuration() > threshold) {
				// Out of time
				return styleOver;
			}
			return styleNormal;
		}
	};
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:24,代码来源:JiraExportPluginResource.java

示例2: toStyleProcessorDistance

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Return the style corresponding to the distance sign.
 */
protected Processor<SlaData> toStyleProcessorDistance(final String styleNormal, final String styleOver) {
	return new Processor<SlaData>() {
		@Override
		public Object getValue(final Deque<Object> contextData) {
			// Get the context
			final SlaData data = (SlaData) contextData.getLast();
			// Check the threshold
			if (data != null && data.getRevisedDueDateDistance() != null && data.getRevisedDueDateDistance() < 0) {
				// Out of time
				return styleOver;
			}
			return styleNormal;
		}
	};
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:19,代码来源:JiraExportPluginResource.java

示例3: formatConjestionDistance

import java.util.Deque; //导入方法依赖的package包/类
private Deque<Integer> formatConjestionDistance(List<RoadConditionItem> conditionItems, int eIndex, double totalDistance) {
    Deque<Integer> dists = new ArrayDeque<Integer>();
    RoadConditionItem item;
    int t;
    double maxIndex = conditionItems.get(conditionItems.size() - 1).curItemEndIndex;
    for (RoadConditionItem conditionItem : conditionItems) {
        conditionItem.curItemEndIndex = (int) (conditionItem.curItemEndIndex / maxIndex * totalDistance);
    }
    for (int i = 0; i < eIndex; i++) {
        item = conditionItems.get(i);
        if (dists.size() == 0) {
            if (item.roadConditionType > RoadConditionItem.ROAD_CONDITION_TYPE_Straightway) {
                dists.offer(i == 0 ? item.curItemEndIndex : item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex);
            }
        } else {
            t = dists.size();
            if ((t & 1) == 1) {//奇数,拥堵长度
                if (item.roadConditionType > RoadConditionItem.ROAD_CONDITION_TYPE_Straightway) {
                    dists.offer(dists.pollLast() + (item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
                } else {
                    dists.offer((item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
                }
            } else {//偶数,顺畅长度
                if (item.roadConditionType > RoadConditionItem.ROAD_CONDITION_TYPE_Straightway) {
                    if (dists.getLast() <= 100) {
                        dists.pollLast();
                        dists.offer(dists.pollLast() + (item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
                    } else {
                        dists.offer((item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
                    }
                } else {
                    dists.offer(dists.pollLast() + (item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
                }
            }
        }
    }
    return dists;
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:39,代码来源:NavigatorService.java

示例4: getRedstoneRealTimeCount

import java.util.Deque; //导入方法依赖的package包/类
public int getRedstoneRealTimeCount(boolean forceSync) {
	Deque<Integer> deque = enterThreadSafe(forceSync);
	try {
		if (deque.isEmpty()) {
			return 0;
		}
		return deque.getLast();
	} finally {
		leaveThreadSafe(forceSync);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:12,代码来源:RedstoneCounter.java

示例5: testCleanupMemoryAvailabilityWaiterOnInterruption

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Test if the  waiter that is waiting on availability of more memory is cleaned up when an interruption occurs
 */
@Test
public void testCleanupMemoryAvailabilityWaiterOnInterruption() throws Exception {
    BufferPool pool = new BufferPool(2, 1, metrics, time, metricGroup);
    long blockTime = 5000;
    pool.allocate(1, maxBlockTimeMs);
    Thread t1 = new Thread(new BufferPoolAllocator(pool, blockTime));
    Thread t2 = new Thread(new BufferPoolAllocator(pool, blockTime));
    // start thread t1 which will try to allocate more memory on to the Buffer pool
    t1.start();
    // sleep for 500ms. Condition variable c1 associated with pool.allocate() by thread t1 will be inserted in the waiters queue.
    Thread.sleep(500);
    Deque<Condition> waiters = pool.waiters();
    // get the condition object associated with pool.allocate() by thread t1
    Condition c1 = waiters.getFirst();
    // start thread t2 which will try to allocate more memory on to the Buffer pool
    t2.start();
    // sleep for 500ms. Condition variable c2 associated with pool.allocate() by thread t2 will be inserted in the waiters queue. The waiters queue will have 2 entries c1 and c2.
    Thread.sleep(500);
    t1.interrupt();
    // sleep for 500ms.
    Thread.sleep(500);
    // get the condition object associated with allocate() by thread t2
    Condition c2 = waiters.getLast();
    t2.interrupt();
    assertNotEquals(c1, c2);
    t1.join();
    t2.join();
    // both the allocate() called by threads t1 and t2 should have been interrupted and the waiters queue should be empty
    assertEquals(pool.queued(), 0);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:34,代码来源:BufferPoolTest.java


注:本文中的java.util.Deque.getLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。