當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。