本文整理汇总了Java中java.util.ArrayDeque.getFirst方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayDeque.getFirst方法的具体用法?Java ArrayDeque.getFirst怎么用?Java ArrayDeque.getFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ArrayDeque
的用法示例。
在下文中一共展示了ArrayDeque.getFirst方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFirstElement
import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
* getFirst() returns first element, or throws NSEE if empty
*/
public void testFirstElement() {
ArrayDeque q = populatedDeque(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.getFirst());
assertEquals(i, q.pollFirst());
}
try {
q.getFirst();
shouldThrow();
} catch (NoSuchElementException success) {}
}
示例2: stopWhileSize
import java.util.ArrayDeque; //导入方法依赖的package包/类
private static void stopWhileSize(ArrayDeque<PerformanceNode> d, ThreadPerformance threadPerformance) {
int s = d.size();
while (s > 0) {
PerformanceNode n = d.getFirst();
if (n.end == 0) {
n.end = System.nanoTime() - startTime;
threadPerformance.active.remove(n);
d.addAll(n.children);
s = d.size();
}
}
}
示例3: stop
import java.util.ArrayDeque; //导入方法依赖的package包/类
public static void stop(String tag) {
if (!enabled.get()) return;
ThreadPerformance threadPerformance = threadNode.get();
synchronized (threadPerformance) {
PerformanceNode last = threadPerformance.active.getLast();
if (last.tag.equals(tag) && !(last instanceof ThreadPerformance)) {
last.end = System.nanoTime() - startTime;
threadPerformance.active.remove(last);
} else {
Log.error("Performance: stopping tag '" + tag + "' when the last tag is '" + last.tag + "'");
PerformanceNode node = null;
for (PerformanceNode performanceNode : threadPerformance.active) {
if (performanceNode.tag.equals(tag)) {
node = performanceNode;
break;
}
}
if (node == null) {
Log.error("Performance: tag '" + tag + "' was never started");
return;
}
ArrayDeque<PerformanceNode> d = new ArrayDeque<PerformanceNode>();
d.add(node);
while (d.size() > 0) {
PerformanceNode n = d.getFirst();
if (n.end == 0) {
n.end = System.nanoTime() - startTime;
threadPerformance.active.remove(n);
d.addAll(n.children);
}
}
}
}
}