本文整理汇总了Java中java.util.Deque.pop方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.pop方法的具体用法?Java Deque.pop怎么用?Java Deque.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Deque
的用法示例。
在下文中一共展示了Deque.pop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setParent
import java.util.Deque; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void setParent(Node<Mesh> parent)
{
this.parent = parent;
Deque<Node<?>> queue = new ArrayDeque<Node<?>>(parent.getNodes().values());
while(!queue.isEmpty())
{
Node<?> node = queue.pop();
if(node.getKind() instanceof Bone)
{
bones.add((Node<Bone>)node);
queue.addAll(node.getNodes().values());
}
}
ImmutableMultimap.Builder<Vertex, Pair<Float, Node<Bone>>> builder = ImmutableMultimap.builder();
for(Node<Bone> bone : getBones())
{
for(Pair<Vertex, Float> b : bone.getKind().getData())
{
builder.put(b.getLeft(), Pair.of(b.getRight(), bone));
}
}
weightMap = builder.build();
}
示例2: floodIndices
import java.util.Deque; //导入方法依赖的package包/类
private Set<Coordinate> floodIndices(final Coordinate coordinate) {
final Set<Coordinate> flood = new LinkedHashSet<>();
final Color floodColor = getColor(coordinate);
final Deque<Coordinate> queue = new LinkedList<>();
queue.add(coordinate);
while (!queue.isEmpty()) {
final Coordinate location = queue.pop();
flood.add(location);
queue.addAll(getNeighbors(location).stream()
.filter(neighbor -> floodColor.equals(getColor(neighbor)) && !flood.contains(neighbor))
.collect(Collectors.toList()));
}
return flood;
}
示例3: afterCompletion
import java.util.Deque; //导入方法依赖的package包/类
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
Object handler, Exception ex) throws Exception {
if (!isTraced(httpServletRequest)) {
return;
}
Deque<ActiveSpan> activeSpanStack = getActiveSpanStack(httpServletRequest);
ActiveSpan activeSpan = activeSpanStack.pop();
for (HandlerInterceptorSpanDecorator decorator : decorators) {
decorator.onAfterCompletion(httpServletRequest, httpServletResponse, handler, ex, activeSpan);
}
activeSpan.deactivate();
}
示例4: onMethodExitFinally
import java.util.Deque; //导入方法依赖的package包/类
@Override
public void onMethodExitFinally(String cls, final String method, String argTypes) {
final long threadId = Thread.currentThread().getId();
//方法无论是return退出还是异常throw退出,都会回调onMethodExitFinally()
//threadMethodStack无需remove,有两个原因:一是同线程可能再次记录调用栈,所以缓存调用栈结构;二是调用栈本身会清空。
Deque<MethodInfo> methodStack = threadMethodStack.get(threadId);
MethodInfo topMethod = methodStack.pop();
Config config = DroidTelescope.getConfig();
if (config == null) {
//TODO 还未初始化好,一般发生在Application.<init>方法中
return;
}
if (config.shouldRecordMethod(topMethod.getWallClockTimeNs(), topMethod.getCpuTimeMs())) {
//弹出当前线程的栈顶Method,如果栈为空了,说明这个栈顶Method是个rootMethod,保存到root列表
if (methodStack.isEmpty()) {
addRootMethod(topMethod);
} else {
//如果当前调用栈不为空,说明此方法是个子方法,于是添加到rootMethod的调用队列当中
MethodInfo rootMethod = methodStack.peekFirst();
rootMethod.addInnerMethod(topMethod);
}
}
}
示例5: main
import java.util.Deque; //导入方法依赖的package包/类
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String input = scan.nextLine();
Deque<Integer> stack = new ArrayDeque();
for (int i = 0; i < input.length(); i++) {
if(input.charAt(i) == '('){
stack.push(i);
} else if(input.charAt(i) == ')'){
int start = stack.pop();
String cont = input.substring(start, i + 1);
System.out.println(cont);
}
}
}
示例6: loadModels
import java.util.Deque; //导入方法依赖的package包/类
private void loadModels()
{
Deque<ResourceLocation> deque = Queues.<ResourceLocation>newArrayDeque();
Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
for (ResourceLocation resourcelocation : this.models.keySet())
{
set.add(resourcelocation);
this.addModelParentLocation(deque, set, (ModelBlock)this.models.get(resourcelocation));
}
while (!((Deque)deque).isEmpty())
{
ResourceLocation resourcelocation1 = (ResourceLocation)deque.pop();
try
{
if (this.models.get(resourcelocation1) != null)
{
continue;
}
ModelBlock modelblock = this.loadModel(resourcelocation1);
this.models.put(resourcelocation1, modelblock);
this.addModelParentLocation(deque, set, modelblock);
}
catch (Exception exception)
{
LOGGER.warn("In parent chain: {}; unable to load model: \'{}\'", new Object[] {JOINER.join(this.getParentPath(resourcelocation1)), resourcelocation1, exception});
}
set.add(resourcelocation1);
}
}
示例7: setAnimation
import java.util.Deque; //导入方法依赖的package包/类
public void setAnimation(Animation animation)
{
this.animation = animation;
Deque<Node<?>> q = new ArrayDeque<Node<?>>(nodes.values());
while(!q.isEmpty())
{
Node<?> node = q.pop();
if(node.getAnimation() != null) continue;
node.setAnimation(animation);
q.addAll(node.getNodes().values());
}
}
示例8: processSplitFlow
import java.util.Deque; //导入方法依赖的package包/类
/**
* Processes each node in split as a DSL Flow.
* @param node represents a single node in the split.
* @return Deque of Job Flows that was obtained from the Node.
*/
private Deque<Flow> processSplitFlow(LabelledTaskNode node) {
TaskParser taskParser = new TaskParser("split_flow", node.stringify(),
false, true);
ComposedRunnerVisitor splitElementVisitor = new ComposedRunnerVisitor();
taskParser.parse().accept(splitElementVisitor);
Deque splitElementDeque = splitElementVisitor.getFlow();
Deque<Flow> elementFlowDeque = new LinkedList<>();
Deque<Flow> resultFlowDeque = new LinkedList<>();
while (!splitElementDeque.isEmpty()) {
if (splitElementDeque.peek() instanceof TaskAppNode) {
TaskAppNode taskAppNode = (TaskAppNode) splitElementDeque.pop();
if (taskAppNode.hasTransitions()) {
handleTransition(elementFlowDeque, taskAppNode);
}
else {
elementFlowDeque.push(
getTaskAppFlow(taskAppNode));
}
}
else if (splitElementDeque.peek() instanceof FlowNode) {
handleFlowForSegment(elementFlowDeque, resultFlowDeque);
splitElementDeque.pop();
}
}
return resultFlowDeque;
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:38,代码来源:ComposedRunnerJobFactory.java
示例9: extractThriftUnionMetadata
import java.util.Deque; //导入方法依赖的package包/类
private ThriftStructMetadata extractThriftUnionMetadata(Type unionType)
{
requireNonNull(unionType, "unionType is null");
Deque<Type> stack = this.stack.get();
if (stack.contains(unionType)) {
String path = Stream.concat(stack.stream(), Stream.of(unionType))
.map(type -> TypeToken.of(type).getRawType().getName())
.collect(joining("->"));
throw new IllegalArgumentException(
"Circular references must be qualified with 'isRecursive' on a @ThriftField annotation in the cycle: " + path);
}
stack.push(unionType);
try {
ThriftUnionMetadataBuilder builder = new ThriftUnionMetadataBuilder(this, unionType);
return builder.build();
}
finally {
Type top = stack.pop();
checkState(
unionType.equals(top),
"ThriftCatalog circularity detection stack is corrupt: expected %s, but got %s",
unionType,
top);
}
}
示例10: process
import java.util.Deque; //导入方法依赖的package包/类
public SlotAllocInfo process() {
LivenessInfo liveness = LivenessAnalyser.computeLiveness(fn);
Set<Label> visited = new HashSet<>();
Deque<Label> open = new ArrayDeque<>();
open.push(fn.code().entryLabel());
AllocatorVisitor visitor = new AllocatorVisitor(liveness);
assignParamSlots(fn.params());
while (!open.isEmpty()) {
Label l = open.pop();
if (visited.add(l)) {
BasicBlock b = fn.code().block(l);
assignSlots(b, visitor);
for (Label n : b.end().nextLabels()) {
open.push(n);
}
}
}
return new SlotAllocInfo(
Collections.unmodifiableMap(valSlots),
Collections.unmodifiableMap(varSlots));
}
示例11: pop
import java.util.Deque; //导入方法依赖的package包/类
private void pop(Call callType, boolean suppressFinish)
{
Deque<Frame> ourStack = ThreadInfo.getStack();
if (!ourStack.isEmpty())
{
Frame frame = ourStack.peek();
if ((frame.callType == callType) ||
(frame.callType == Call.AVAILABLE_AND_TRANSFORM && callType == Call.AVAILABLE))
{
int size = ourStack.size();
String ms = ms(System.currentTimeMillis() - frame.start);
logInfo(frame, size, ms);
boolean firstLevel = size == 1;
if (!suppressFinish && (firstLevel || logger.isTraceEnabled()))
{
log(FINISHED_IN + ms +
(frame.callType == Call.AVAILABLE ? " Transformer NOT called" : "") +
(firstLevel ? "\n" : ""),
firstLevel);
}
setDebugOutput(frame.origDebugOutput);
ourStack.pop();
}
}
}
示例12: zip
import java.util.Deque; //导入方法依赖的package包/类
/**
* @source http://stackoverflow.com/a/1399432
*/
public static void zip(File directory, File zipfile) throws Exception {
if (directory.listFiles() == null || directory.listFiles().length == 0) {
return;
}
URI base = directory.toURI();
Deque<File> queue = new LinkedList<File>();
queue.push(directory);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipfile)));
try {
while (!queue.isEmpty()) {
directory = queue.pop();
for (File path : directory.listFiles()) {
String name = base.relativize(path.toURI()).getPath();
if (path.isDirectory()) {
queue.push(path);
name = name.endsWith("/") ? name : name + "/";
out.putNextEntry(new ZipEntry(name));
} else {
out.putNextEntry(new ZipEntry(name));
copy(path, out);
out.closeEntry();
}
}
}
} finally {
out.close();
}
}
示例13: printFromTopToBottom
import java.util.Deque; //导入方法依赖的package包/类
public void printFromTopToBottom(TreeNode root) {
if (root == null) return;
Deque<TreeNode> queue = new ArrayDeque<>();
queue.addLast(root);
while (!queue.isEmpty()) {
TreeNode node = queue.pop();
System.out.print(node.val + " ");
if (node.left != null)
queue.addLast(node.left);
if (node.right != null)
queue.addLast(node.right);
}
}
示例14: loadModels
import java.util.Deque; //导入方法依赖的package包/类
private void loadModels()
{
Deque<ResourceLocation> deque = Queues.<ResourceLocation>newArrayDeque();
Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
for (ResourceLocation resourcelocation : this.models.keySet())
{
set.add(resourcelocation);
ResourceLocation resourcelocation1 = ((ModelBlock)this.models.get(resourcelocation)).getParentLocation();
if (resourcelocation1 != null)
{
deque.add(resourcelocation1);
}
}
while (!((Deque)deque).isEmpty())
{
ResourceLocation resourcelocation2 = (ResourceLocation)deque.pop();
try
{
if (this.models.get(resourcelocation2) != null)
{
continue;
}
ModelBlock modelblock = this.loadModel(resourcelocation2);
this.models.put(resourcelocation2, modelblock);
ResourceLocation resourcelocation3 = modelblock.getParentLocation();
if (resourcelocation3 != null && !set.contains(resourcelocation3))
{
deque.add(resourcelocation3);
}
}
catch (Exception exception)
{
LOGGER.warn((String)("In parent chain: " + JOINER.join(this.getParentPath(resourcelocation2)) + "; unable to load model: \'" + resourcelocation2 + "\'"), (Throwable)exception);
}
set.add(resourcelocation2);
}
}
示例15: sortMapsToLoad
import java.util.Deque; //导入方法依赖的package包/类
/**
* Returns a list of concept maps in the order they need to be loaded.
*/
private static List<String> sortMapsToLoad(Set<String> mapsToLoad,
Map<String,ConceptMap> allMaps) {
Deque<String> pendingMaps = new ArrayDeque<>(mapsToLoad);
List<String> loadOrder = new ArrayList<>();
Set<String> loadedMaps = new HashSet<>();
while (!pendingMaps.isEmpty()) {
String nextMap = pendingMaps.peek();
// If the map has already been loaded,
// remove it and continue.
if (loadedMaps.contains(nextMap)) {
pendingMaps.pop();
continue;
}
ConceptMap mapToLoad = allMaps.get(nextMap);
if (mapToLoad == null) {
throw new IllegalStateException("Concept map " + nextMap + " "
+ " is referenced but not in the collection of concept maps.");
}
// Get the set of children we need to load before the pending map.
Set<String> childrenToLoad = getMapChildren(mapToLoad);
childrenToLoad.removeAll(loadedMaps);
// If the pending map has no children to load, we can
// add it to our load order.
if (childrenToLoad.isEmpty()) {
loadedMaps.add(nextMap);
loadOrder.add(nextMap);
pendingMaps.pop();
} else {
// The pending map has children, so we need to load them first.
for (String child: childrenToLoad) {
pendingMaps.push(child);
}
}
}
return loadOrder;
}