コード例 #1
0
  // undo
  // 从undoQueue中删除并放到redoQueue中
  public String undo() {

    String last = undoQueue.pollLast();
    if (last != null) {
      redoQueue.addLast(last);
    }

    return undoQueue.peekLast();
  }
コード例 #2
0
  void handleWorkUnitComplete(WorkUnit w) {
    for (int depId : w.getDependencyIds()) {
      m_missingDependencies.remove(depId);
    }
    // slide this new stack frame drop into the right position
    // (before any other stack frame drops)
    if ((w.shouldResumeProcedure())
        && (m_readyWorkUnits.peekLast() != null)
        && (m_readyWorkUnits.peekLast().shouldResumeProcedure())) {

      ArrayDeque<WorkUnit> deque = new ArrayDeque<WorkUnit>();
      while ((m_readyWorkUnits.peekLast() != null)
          && (m_readyWorkUnits.peekLast().shouldResumeProcedure())) {
        deque.add(m_readyWorkUnits.pollLast());
      }
      deque.add(w);
      while (deque.size() > 0) m_readyWorkUnits.add(deque.pollLast());
    } else {
      m_readyWorkUnits.add(w);
    }
  }
コード例 #3
0
ファイル: XPathParser.java プロジェクト: Buzov/jlibs-1
 /** pops from current frame */
 private Object pop() {
   return peekFrame.pollLast();
 }
コード例 #4
0
ファイル: XPathParser.java プロジェクト: Buzov/jlibs-1
 private ArrayDeque popFrame() {
   ArrayDeque frame = frames.pollLast();
   peekFrame = frames.peekLast();
   return frame;
 }
コード例 #5
0
ファイル: XPathParser.java プロジェクト: Buzov/jlibs-1
 private void endStep() {
   stepStack.pollLast();
 }
コード例 #6
0
ファイル: AI.java プロジェクト: joshlava/33333
  public static void recur(int[][] board, int z) {
    int[][] tempBoard = new int[4][4];
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        tempBoard[i][j] = board[i][j];
      }
    }
    Moves.storeNext();
    // GUI.ThreesGUI gui = new GUI.ThreesGUI();
    ArrayDeque<String> finalmoves = new ArrayDeque<String>();
    ArrayDeque<String> temp = new ArrayDeque<String>();
    LinkedList<Object> temp2 = new LinkedList<Object>();
    LinkedList<Object> temp3 = new LinkedList<Object>();

    String nextMove = "";
    for (int i = 0; i < z; i++) {

      temp = new ArrayDeque<String>(AStar(tempBoard, 50));

      temp.poll();
      temp.poll();
      tempBoard = GUI.Threes.board.clone();

      temp3 = Moves.doMove(tempBoard, temp, false);
      temp3.poll();
      temp3.poll();
      int k = 0;
      boolean gameon = true;
      while (!temp.isEmpty() && k < 5 && gameon) {
        nextMove = temp.pollLast();

        if (nextMove.equals("L")) {
          gameon = GUI.Threes.Left();
        } else if (nextMove.equals("R")) {
          gameon = GUI.Threes.Right();
        } else if (nextMove.equals("U")) {
          gameon = GUI.Threes.Up();
        } else if (nextMove.equals("D")) {
          gameon = GUI.Threes.Down();
        } else nextMove = "X";
        k++;
        if (!nextMove.equals("X") && gameon) {
          finalmoves.addFirst(nextMove);
          Moves.popNext();
        }
      }
      // tempBoard = GUI.Threes.board.clone();

      // if(!nextMove.equals("X"))
      // finalmoves.addFirst(nextMove);
      // Moves.popNext();
      if (!gameon) {
        i = z;
      }
    }
    System.out.println("contents of finalmoves");
    int movesize = finalmoves.size();
    ArrayDeque<String> printemp = new ArrayDeque<String>(finalmoves);
    for (int i = 0; i < movesize; i++) {
      System.out.print(printemp.remove());
    }
    System.out.println();
    temp2 = Moves.doMove(board, finalmoves, true);
    System.out.println("heuristic score was: " + temp2.remove(0));

    System.out.println("Final score was: " + temp2.remove(0));
    GUI.Threes.finalBoard();

    System.out.println("Move string was");
    while (!temp2.isEmpty()) {
      System.out.print(temp2.remove());
    }
    System.out.println();
  }