本文整理匯總了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);
}
}
}
}
}