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


Java ArrayDeque.push方法代码示例

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


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

示例1: arrayDequeStuff

import java.util.ArrayDeque; //导入方法依赖的package包/类
static void arrayDequeStuff() {
  ArrayDeque<Object> d = new ArrayDeque<>();
  // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
  d.add(null);
  // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
  d.addFirst(null);
  // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
  d.addLast(null);
  // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
  d.offerFirst(null);
  // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
  d.offerLast(null);
  // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
  d.offer(null);
  // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
  d.push(null);
  // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
  d.toArray(null);
  // this should be fine
  d.toArray();
}
 
开发者ID:uber,项目名称:NullAway,代码行数:22,代码来源:NullAwayNativeModels.java

示例2: findCallSite

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * Locate a late inline call site: find, in this instance's
 * {@linkplain #calls call sites}, the one furthest down the given call
 * stack.
 *
 * Multiple chains of identical call sites with the same method name / bci
 * combination are possible, so we have to try them all until we find the
 * late inline call site that has a matching inline ID.
 *
 * @return a matching call site, or {@code null} if none was found.
 */
public CallSite findCallSite(ArrayDeque<CallSite> sites) {
    if (calls == null) {
        return null;
    }
    CallSite site = sites.pop();
    for (CallSite c : calls) {
        if (c.matches(site)) {
            if (!sites.isEmpty()) {
                CallSite res = c.findCallSite(sites);
                if (res != null) {
                    sites.push(site);
                    return res;
                }
            } else {
                sites.push(site);
                return c;
            }
        }
    }
    sites.push(site);
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:CallSite.java

示例3: isBalanced

import java.util.ArrayDeque; //导入方法依赖的package包/类
private static boolean isBalanced(String expression, HashMap<Character, Character> map) {
    if ((expression.length() % 2) != 0) {
        return false; // odd length Strings are not balanced
    }        
    ArrayDeque<Character> deque = new ArrayDeque<>(); // use deque as a stack
    for (int i = 0; i < expression.length(); i++) {
        Character ch = expression.charAt(i);
        if (map.containsKey(ch)) {
            deque.push(ch);
        } else if (deque.isEmpty() || ch != map.get(deque.pop())) {
            return false;
        }
    }
    return deque.isEmpty();
}
 
开发者ID:rshaghoulian,项目名称:HackerRank_solutions,代码行数:16,代码来源:Solution.java

示例4: isBalanced

import java.util.ArrayDeque; //导入方法依赖的package包/类
private static boolean isBalanced(String expression, HashMap<Character, Character> map) {
    if ((expression.length() % 2) != 0) {
        return false;
    }
    ArrayDeque<Character> deque = new ArrayDeque<>();
    for (int i = 0; i < expression.length(); i++) {
        Character ch = expression.charAt(i);
        if (map.containsKey(ch)) {
            deque.push(ch);
        } else if (deque.isEmpty() || ch != map.get(deque.pop())) {
            return false;
        }
    }
    return deque.isEmpty();
}
 
开发者ID:Kvaibhav01,项目名称:HackerRank-in-Java,代码行数:16,代码来源:Java Stack.java

示例5: floodFillTarget

import java.util.ArrayDeque; //导入方法依赖的package包/类
public int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) {
    int cnt = 0;
    ArrayDeque<int[]> stack = new ArrayDeque<>();
    stack.push(new int[]{x, y});

    while (!stack.isEmpty()) {
        int[] nxt = stack.pop();
        x = nxt[0];
        y = nxt[1];
        if (source.getFlag(x, y)) { // Set in src
            source.setFlag(x, y, false); // Clear source
            destination.setFlag(x, y, true); // Set in destination
            cnt++;
            if (source.getFlag(x + 1, y)) {
                stack.push(new int[]{x + 1, y});
            }
            if (source.getFlag(x - 1, y)) {
                stack.push(new int[]{x - 1, y});
            }
            if (source.getFlag(x, y + 1)) {
                stack.push(new int[]{x, y + 1});
            }
            if (source.getFlag(x, y - 1)) {
                stack.push(new int[]{x, y - 1});
            }
        }
    }
    return cnt;
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:30,代码来源:EngineDynmap.java

示例6: releaseFloatingNode

import java.util.ArrayDeque; //导入方法依赖的package包/类
private void releaseFloatingNode(Node node) {
    ArrayDeque<Node> cachedNodes = reusableFloatingNodes.get(node.getNodeClass());
    if (cachedNodes == null) {
        cachedNodes = new ArrayDeque<>(2);
        reusableFloatingNodes.put(node.getNodeClass(), cachedNodes);
    }
    cachedNodes.push(node);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:GraphDecoder.java

示例7: testPushNull

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * push(null) throws NPE
 */
public void testPushNull() {
    ArrayDeque q = new ArrayDeque(1);
    try {
        q.push(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ArrayDequeTest.java

示例8: testPush

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * peekFirst() returns element inserted with push
 */
public void testPush() {
    ArrayDeque q = populatedDeque(3);
    q.pollLast();
    q.push(four);
    assertSame(four, q.peekFirst());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:ArrayDequeTest.java

示例9: fixFrameStates

import java.util.ArrayDeque; //导入方法依赖的package包/类
private static void fixFrameStates(StructuredGraph graph, MergeNode originalMerge, PhiNode returnPhi) {
    // It is possible that some of the frame states that came from AFTER_BCI reference a Phi
    // node that was created to merge multiple returns. This can create cycles
    // (see GR-3949 and GR-3957).
    // To detect this, we follow the control paths starting from the merge node,
    // split the Phi node inputs at merges and assign the proper input to each frame state.
    NodeMap<Node> seen = new NodeMap<>(graph);
    ArrayDeque<Node> workList = new ArrayDeque<>();
    ArrayDeque<ValueNode> valueList = new ArrayDeque<>();
    workList.push(originalMerge);
    valueList.push(returnPhi);
    while (!workList.isEmpty()) {
        Node current = workList.pop();
        ValueNode currentValue = valueList.pop();
        if (seen.containsKey(current)) {
            continue;
        }
        seen.put(current, current);
        if (current instanceof StateSplit && current != originalMerge) {
            StateSplit stateSplit = (StateSplit) current;
            FrameState state = stateSplit.stateAfter();
            if (state != null && state.values().contains(returnPhi)) {
                int index = 0;
                FrameState duplicate = state.duplicate();
                for (ValueNode value : state.values()) {
                    if (value == returnPhi) {
                        duplicate.values().set(index, currentValue);
                    }
                    index++;
                }
                stateSplit.setStateAfter(duplicate);
                GraphUtil.tryKillUnused(state);
            }
        }
        if (current instanceof AbstractMergeNode) {
            AbstractMergeNode currentMerge = (AbstractMergeNode) current;
            for (EndNode pred : currentMerge.cfgPredecessors()) {
                ValueNode newValue = currentValue;
                if (currentMerge.isPhiAtMerge(currentValue)) {
                    PhiNode currentPhi = (PhiNode) currentValue;
                    newValue = currentPhi.valueAt(pred);
                }
                workList.push(pred);
                valueList.push(newValue);
            }
        } else if (current.predecessor() != null) {
            workList.push(current.predecessor());
            valueList.push(currentValue);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:InliningUtil.java


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