Esempio n. 1
0
  private void play() {
    if (isReload) reloadGame();
    if (isEnd || isPause) return;

    addFeed();
    doesEatFeed();
    addRegime();
    doesEatRegime();
    crossBorder();

    head = blocks.peekFirst();

    Block newHead = new Block(head.getX() + dx[inputDirection], head.getY() + dy[inputDirection]);
    Rectangle headRect = new Rectangle(head.getX(), head.getY(), 10, 10);

    if (isEnd(newHead)) {
      isEnd = true;
      //            Image image = new Image(this.getClass().getResourceAsStream("/gameOver.png"));
      //            ImageView imageView = new ImageView(image);
      //            group.getChildren().add(imageView);
      //            scene.setOnKeyPressed(null);
      saveRecord();
      showRecord();
      return;
    } else {
      blocks.push(newHead);
      rectangles.push(headRect);

      blocks.pollLast();

      updateGui();
    }
  }
Esempio n. 2
0
  private void reloadGame() {
    if (!isReload) return;

    score = 0;
    isReload = false;
    isEnd = false;
    feedCounter1 = 0;
    feedCounter2 = 0;

    List<Rectangle> rectangleList = new ArrayList<>(rectangles);
    for (Rectangle r : rectangleList) group.getChildren().remove(r);

    regimeRectangle.setX(-20);

    Deque<Block> blocksTemp = new ArrayDeque<>();
    Deque<Rectangle> rectanglesTemp = new ArrayDeque<>();

    head = new Block(100, 150);
    tale = new Block(90, 150);

    if (inputDirection != 3) {
      blocksTemp.push(tale);
      blocksTemp.push(head);

      rectanglesTemp.push(new Rectangle(tale.getX(), tale.getY(), 10, 10));
      rectanglesTemp.push(new Rectangle(head.getX(), head.getY(), 10, 10));
    } else {
      blocksTemp.push(head);
      blocksTemp.push(tale);

      rectanglesTemp.push(new Rectangle(head.getX(), head.getY(), 10, 10));
      rectanglesTemp.push(new Rectangle(tale.getX(), tale.getY(), 10, 10));
    }

    blocks = blocksTemp;
    rectangles = rectanglesTemp;

    group.getChildren().add(rectangles.getFirst());
    group.getChildren().add(rectangles.getLast());

    timer.cancel();
    timer = null;
    timer = new Timer();

    timer.schedule(
        new TimerTask() {
          @Override
          public void run() {
            Platform.runLater(() -> play());
          }
        },
        1,
        100);
  }
  @Override
  public void meet(FunctionCall fc) throws RuntimeException {
    // special optimizations for frequent cases with variables
    if ((XMLSchema.DOUBLE.toString().equals(fc.getURI())
            || XMLSchema.FLOAT.toString().equals(fc.getURI()))
        && fc.getArgs().size() == 1) {
      optypes.push(ValueType.DOUBLE);
      fc.getArgs().get(0).visit(this);
      optypes.pop();
    } else if ((XMLSchema.INTEGER.toString().equals(fc.getURI())
            || XMLSchema.INT.toString().equals(fc.getURI()))
        && fc.getArgs().size() == 1) {
      optypes.push(ValueType.INT);
      fc.getArgs().get(0).visit(this);
      optypes.pop();
    } else if (XMLSchema.BOOLEAN.toString().equals(fc.getURI()) && fc.getArgs().size() == 1) {
      optypes.push(ValueType.BOOL);
      fc.getArgs().get(0).visit(this);
      optypes.pop();
    } else if (XMLSchema.DATE.toString().equals(fc.getURI()) && fc.getArgs().size() == 1) {
      optypes.push(ValueType.DATE);
      fc.getArgs().get(0).visit(this);
      optypes.pop();
    } else {

      String fnUri = fc.getURI();

      String[] args = new String[fc.getArgs().size()];

      NativeFunction nf = functionRegistry.get(fnUri);

      if (nf != null && nf.isSupported(parent.getDialect())) {

        for (int i = 0; i < args.length; i++) {
          args[i] =
              new ValueExpressionEvaluator(fc.getArgs().get(i), parent, nf.getArgumentType(i))
                  .build();
        }

        if (optypes.peek() != nf.getReturnType()) {
          builder.append(castExpression(nf.getNative(parent.getDialect(), args), optypes.peek()));
        } else {
          builder.append(nf.getNative(parent.getDialect(), args));
        }
      } else {
        throw new IllegalArgumentException(
            "the function " + fnUri + " is not supported by the SQL translation");
      }
    }
  }
  @Override
  public void meet(MathExpr expr) throws RuntimeException {
    ValueType ot = new OPTypeFinder(expr).coerce();

    if (ot == ValueType.STRING) {
      if (expr.getOperator() == MathExpr.MathOp.PLUS) {
        builder.append(
            functionRegistry
                .get(FN.CONCAT.stringValue())
                .getNative(
                    parent.getDialect(),
                    new ValueExpressionEvaluator(expr.getLeftArg(), parent, ot).build(),
                    new ValueExpressionEvaluator(expr.getRightArg(), parent, ot).build()));
      } else {
        throw new IllegalArgumentException(
            "operation " + expr.getOperator() + " is not supported on strings");
      }
    } else {
      if (ot == ValueType.NODE || ot == ValueType.TERM) {
        ot = ValueType.DOUBLE;
      }

      optypes.push(ot);
      expr.getLeftArg().visit(this);
      builder.append(getSQLOperator(expr.getOperator()));
      expr.getRightArg().visit(this);
      optypes.pop();
    }
  }
  @Override
  public void meet(Count node) throws RuntimeException {
    builder.append("COUNT(");

    if (node.isDistinct()) {
      builder.append("DISTINCT ");
    }

    if (node.getArg() == null) {
      // this is a weird special case where we need to expand to all variables selected in the query
      // wrapped
      // by the group; we cannot simply use "*" because the concept of variables is a different one
      // in SQL,
      // so instead we construct an ARRAY of the bindings of all variables

      List<String> countVariables = new ArrayList<>();
      for (SQLVariable v : parent.getVariables().values()) {
        if (v.getProjectionType() == ValueType.NONE) {
          Preconditions.checkState(
              v.getExpressions().size() > 0, "no expressions available for variable");

          countVariables.add(v.getExpressions().get(0));
        }
      }
      builder.append("ARRAY[");
      Joiner.on(',').appendTo(builder, countVariables);
      builder.append("]");

    } else {
      optypes.push(ValueType.NODE);
      node.getArg().visit(this);
      optypes.pop();
    }
    builder.append(")");
  }
 private InstructionImpl startNode(@Nullable GroovyPsiElement element, boolean checkPending) {
   final InstructionImpl instruction = new InstructionImpl(element);
   addNode(instruction);
   if (checkPending) checkPending(instruction);
   myProcessingStack.push(instruction);
   return instruction;
 }
 @Override
 public void enterFacilityDecl(ResolveParser.FacilityDeclContext ctx) {
   VCAssertiveBlockBuilder block =
       new VCAssertiveBlockBuilder(g, moduleScope, "Facility_Inst=" + ctx.name.getText(), ctx);
   block.assume(g.getTrueExp());
   assertiveBlocks.push(block);
 }
  @Override
  public void enterProcedureDecl(ResolveParser.ProcedureDeclContext ctx) {
    Scope s = symtab.getScope(ctx);
    try {
      List<ProgParameterSymbol> paramSyms = s.getSymbolsOfType(ProgParameterSymbol.class);

      currentProcOpSym =
          s.queryForOne(
              new OperationQuery(
                  null, ctx.name, Utils.apply(paramSyms, ProgParameterSymbol::getDeclaredType)));

      // This is the requires for the operation with some substutions made (see corrFnExp rule in
      // HH-diss)
      PExp corrFnExpRequires =
          perParameterCorrFnExpSubstitute(paramSyms, currentProcOpSym.getRequires());
      List<PExp> opParamAntecedents = new ArrayList<>();
      Utils.apply(paramSyms, opParamAntecedents, this::extractAssumptionsFromParameter);
      Set<PExp> l = getModuleLevelAssertionsOfType(ClauseType.REQUIRES);
      VCAssertiveBlockBuilder block =
          new VCAssertiveBlockBuilder(g, s, "Correct_Op_Hypo=" + ctx.name.getText(), ctx)
              .facilitySpecializations(facilitySpecFormalActualMappings)
              .assume(getModuleLevelAssertionsOfType(ClauseType.REQUIRES))
              // TODO: constraints should be added on demand via NOTICE:...
              // .assume(getModuleLevelAssertionsOfType(ClauseType.CONSTRAINT))
              .assume(opParamAntecedents) // we assume correspondence for reprs here automatically
              .assume(corrFnExpRequires)
              .remember();
      assertiveBlocks.push(block);
    } catch (SymbolTableException e) {
      throw new RuntimeException(e); // this shouldn't happen now
    }
  }
  @Override
  public void meet(If node) throws RuntimeException {
    builder.append("CASE WHEN ");

    optypes.push(ValueType.BOOL);
    node.getCondition().visit(this);
    optypes.pop();

    optypes.push(new OPTypeFinder(node).coerce());
    builder.append(" THEN ");
    node.getResult().visit(this);
    builder.append(" ELSE ");
    node.getAlternative().visit(this);
    builder.append(" END");
    optypes.pop();
  }
 @Override
 public void meet(Sum node) throws RuntimeException {
   builder.append("SUM(");
   optypes.push(ValueType.DOUBLE);
   node.getArg().visit(this);
   optypes.pop();
   builder.append(")");
 }
 @Override
 public void meet(Compare cmp) throws RuntimeException {
   optypes.push(new OPTypeFinder(cmp).coerce());
   cmp.getLeftArg().visit(this);
   builder.append(getSQLOperator(cmp.getOperator()));
   cmp.getRightArg().visit(this);
   optypes.pop();
 }
Esempio n. 12
0
  // returns the single move to make given a board, depth, piecelist, heuristic
  // whill choose the best terminal board at the max depth,
  // or if none exists, the best board with no children (inevitable death)
  public Board.Direction nextMove(Board start, List<Integer> nextPiece) {
    int maxDepth = Math.min(exploreDepth, nextPiece.size());

    double bestLiveScore = -1;
    Board.Direction bestLiveDirection = null; // cus why not?

    // add the first round seperately so we know which move to return
    for (Board.Direction d : Board.Direction.values()) {
      Board next = start.move(d, nextPiece.get(0));
      if (next != null) {
        PriorityQueue<Double> pq = new PriorityQueue<Double>();

        Deque<StackItem> stack = new ArrayDeque<StackItem>();
        stack.push(new StackItem(next, 1, d));
        // DFS
        while (!stack.isEmpty()) {
          StackItem cur = stack.pop();

          // add more moves if not beyond max depth
          if (cur.d < maxDepth) {
            for (Board.Direction d2 : Board.Direction.values()) {
              Board next2 = cur.b.move(d2, nextPiece.get(cur.d));
              if (next2 != null) {
                stack.push(new StackItem(next2, cur.d + 1, cur.move));
              }
            }
          }
          // update live only at the bottom of the tree
          if (cur.d == maxDepth) {
            pq.add(heuristic.useHeuristic(cur.b));
            if (pq.size() > 10) pq.poll();
          }
        }
        double sum = 0;
        int count = 0;
        count = pq.size();
        while (!pq.isEmpty()) sum += pq.poll();
        if (count > 0 && sum / count > bestLiveScore) {
          bestLiveScore = sum / count;
          bestLiveDirection = d;
        }
      }
    }
    return bestLiveDirection;
  }
Esempio n. 13
0
  public int execute(String input) {
    Deque<Integer> stack = new ArrayDeque<>();

    for (String s : input.split("\\s")) {
      Operator operator = opetators.get(s);

      if (operator != null) {
        Integer num1 = stack.pop();
        Integer num2 = stack.pop();
        stack.push(operator.execute(num1, num2));

      } else {
        stack.push(Integer.valueOf(s));
      }
    }

    return stack.pop();
  }
Esempio n. 14
0
  private void doesEatFeed() {
    if (isEnd) return;

    if (Math.abs(blocks.peekFirst().getX() - feedRectangle.getX()) < 10
        && Math.abs(blocks.peekFirst().getY() - feedRectangle.getY()) < 10) {
      feedRectangle.setX(1200);
      isFeed = false;
      ++feedCounter2;
      ++score;
      scoreLabel.setText(String.valueOf(score));

      head = blocks.peekFirst();
      Block newHead = new Block(head.getX() + dx[inputDirection], head.getY() + dy[inputDirection]);
      Rectangle headRect = new Rectangle(head.getX(), head.getY(), 10, 10);
      blocks.push(newHead);
      rectangles.push(headRect);
    }
  }
 @Override
 public void meet(SameTerm cmp) throws RuntimeException {
   // covered by value binding in variables
   optypes.push(ValueType.TERM);
   cmp.getLeftArg().visit(this);
   builder.append(" = ");
   cmp.getRightArg().visit(this);
   optypes.pop();
 }
Esempio n. 16
0
  public void run() {
    Deque<VisitingContext> stack = new ArrayDeque<>();

    stack.add(new VisitingContext(rootNode));
    boolean goOn = stack.peek().hasNext();

    if (goOn) {
      do {
        Map.Entry<String, JsonValue> current = stack.peek().nextElement();

        if (!(current.getValue() instanceof JsonStructure)) {
          String key = stack.peek().getNSPrefix() + current.getKey();
          String value = null;
          JsonValue jsonValue = current.getValue();
          switch (jsonValue.getValueType()) {
            case NULL:
              value = null;
              break;
            case FALSE:
              value = Boolean.FALSE.toString();
              break;
            case TRUE:
              Boolean.TRUE.toString();
              break;
            case NUMBER:
              value = jsonValue.toString();
              break;
            case STRING:
              value = ((JsonString) jsonValue).getString();
              break;
            default:
              throw new ConfigException("Internal failure while processing JSON document.");
          }

          targetStore.put(key, value);
        } else if (current.getValue() instanceof JsonObject) {
          String key = stack.peek().getNSPrefix() + current.getKey();
          JsonObject node = (JsonObject) current.getValue();
          stack.push(new VisitingContext(node, key));
        } else if (current.getValue() instanceof JsonArray) {
          throw new ConfigException("Arrays are not supported at the moment.");
        } else {
          throw new ConfigException("Internal failure while processing JSON document.");
        }

        goOn = stack.peek().hasNext();

        while (!goOn && stack.size() > 0) {
          stack.remove();
          goOn = (stack.size() > 0) && stack.peek().hasNext();
        }
      } while (goOn);
    }
  }
Esempio n. 17
0
 @Override
 public boolean add(@NotNull final ByteIterable key, @NotNull final ByteIterable value) {
   final ByteIterator it = key.iterator();
   NodeBase node = root;
   MutableNode mutableNode = null;
   final Deque<ChildReferenceTransient> stack = new ArrayDeque<>();
   while (true) {
     final NodeBase.MatchResult matchResult = node.matchesKeySequence(it);
     final int matchingLength = matchResult.matchingLength;
     if (matchingLength < 0) {
       final MutableNode prefix =
           node.getMutableCopy(this).splitKey(-matchingLength - 1, matchResult.keyByte);
       if (matchResult.hasNext) {
         prefix.hang(matchResult.nextByte, it).setValue(value);
       } else {
         prefix.setValue(value);
       }
       if (stack.isEmpty()) {
         root = new MutableRoot(prefix, root.sourceAddress);
       } else {
         final ChildReferenceTransient parent = stack.pop();
         mutableNode = parent.mutate(this);
         mutableNode.setChild(parent.firstByte, prefix);
       }
       break;
     }
     if (!it.hasNext()) {
       if (node.hasValue()) {
         return false;
       }
       mutableNode = node.getMutableCopy(this);
       mutableNode.setValue(value);
       break;
     }
     final byte nextByte = it.next();
     final NodeBase child = node.getChild(this, nextByte);
     if (child == null) {
       mutableNode = node.getMutableCopy(this);
       if (mutableNode.hasChildren() || mutableNode.hasKey() || mutableNode.hasValue()) {
         mutableNode.hang(nextByte, it).setValue(value);
       } else {
         mutableNode.setKeySequence(new ArrayByteIterable(nextByte, it));
         mutableNode.setValue(value);
       }
       break;
     }
     stack.push(new ChildReferenceTransient(nextByte, node));
     node = child;
   }
   ++size;
   mutateUp(stack, mutableNode);
   TreeCursorMutable.notifyCursors(this);
   return true;
 }
 public static boolean bfsIterative(TreeNode root, int val) {
   Deque<TreeNode> s = new LinkedList<>();
   s.push(root);
   while (!s.isEmpty()) {
     TreeNode curr = s.removeFirst();
     if (curr.left != null) s.addLast(curr.left);
     if (curr.right != null) s.addLast(curr.right);
     if (curr.value == val) return true;
   }
   return false;
 }
  private void addExternalParents(EntityType entityType) {
    Deque<Type> superTypes = new ArrayDeque<Type>();
    if (entityType.getSuperType() != null) {
      superTypes.push(entityType.getSuperType().getType());
    }

    while (!superTypes.isEmpty()) {
      Type superType = superTypes.pop();
      if (!context.allTypes.containsKey(superType.getFullName())) {
        TypeElement typeElement =
            processingEnv.getElementUtils().getTypeElement(superType.getFullName());
        if (typeElement == null) {
          throw new IllegalStateException("Found no type for " + superType.getFullName());
        }
        EntityType superEntityType = elementHandler.handleEntityType(typeElement);
        if (superEntityType.getSuperType() != null) {
          superTypes.push(superEntityType.getSuperType().getType());
        }
        context.allTypes.put(superType.getFullName(), superEntityType);
      }
    }
  }
  public ValueExpressionEvaluator(ValueExpr expr, SQLBuilder parent, ValueType optype) {
    this.parent = parent;

    optypes.push(optype);

    if (log.isTraceEnabled()) {
      long start = System.currentTimeMillis();
      expr.visit(this);
      log.trace("expression evaluated in {} ms", (System.currentTimeMillis() - start));
    } else {
      expr.visit(this);
    }
  }
  @Override
  public void meet(Bound node) throws RuntimeException {
    ValueExpr arg = node.getArg();

    if (arg instanceof ValueConstant) {
      builder.append(Boolean.toString(true));
    } else if (arg instanceof Var) {
      builder.append("(");
      optypes.push(ValueType.NODE);
      arg.visit(this);
      optypes.pop();
      builder.append(" IS NOT NULL)");
    }
  }
 private List<Element> createConnectedComponent(
     Map<Element, ElementStatus> elementStatusMap, Element root) {
   List<Element> connectedComponent = new ArrayList<>();
   Deque<Element> stack = new ArrayDeque<>();
   stack.push(root);
   while (!stack.isEmpty()) {
     Element element = stack.pop();
     if (ElementStatus.UNREACHABLE.equals(elementStatusMap.get(element))) {
       connectedComponent.add(element);
       elementStatusMap.put(element, ElementStatus.REACHABLE);
       if (element instanceof RuntimeVertex) {
         RuntimeVertex vertex = (RuntimeVertex) element;
         for (RuntimeEdge edge : context.getModel().getOutEdges(vertex)) {
           stack.push(edge);
         }
       } else if (element instanceof RuntimeEdge) {
         RuntimeEdge edge = (RuntimeEdge) element;
         stack.push(edge.getTargetVertex());
       }
     }
   }
   return Collections.unmodifiableList(connectedComponent);
 }
Esempio n. 23
0
  private void crossBorder() {
    if (isEnd) return;

    List<Block> blockTemp = new ArrayList<>(blocks);
    switch (inputDirection) {
      case 0:
        for (int i = 0; i < blockTemp.size(); i++)
          if (blockTemp.get(i).getY() >= 460) {
            Block temp = blockTemp.get(i);
            temp.setY(0);
            blockTemp.set(i, temp);
          }
        break;

      case 1:
        for (int i = 0; i < blockTemp.size(); i++)
          if (blockTemp.get(i).getX() >= 490) {
            Block temp = blockTemp.get(i);
            temp.setX(0);
            blockTemp.set(i, temp);
          }
        break;

      case 2:
        for (int i = 0; i < blockTemp.size(); i++)
          if (blockTemp.get(i).getY() <= 0) {
            Block temp = blockTemp.get(i);
            temp.setY(450);
            blockTemp.set(i, temp);
          }
        break;

      case 3:
        for (int i = 0; i < blockTemp.size(); i++)
          if (blockTemp.get(i).getX() <= 0) {
            Block temp = blockTemp.get(i);
            temp.setX(480);
            blockTemp.set(i, temp);
          }
        break;
    }

    Deque<Block> blocksTemp = new ArrayDeque<>();

    for (int i = blockTemp.size() - 1; i >= 0; i--) blocksTemp.push(blockTemp.get(i));

    blocks = blocksTemp;
  }
 @Override
 public void meet(BNodeGenerator gen) throws RuntimeException {
   if (gen.getNodeIdExpr() != null) {
     // get value of argument and express it as string
     optypes.push(ValueType.STRING);
     gen.getNodeIdExpr().visit(this);
     optypes.pop();
   } else {
     builder
         .append("'")
         .append(
             Long.toHexString(System.currentTimeMillis())
                 + Integer.toHexString(anonIdGenerator.nextInt(1000)))
         .append("'");
   }
 }
Esempio n. 25
0
  @Override
  public void enterTypeImplInit(ResolveParser.TypeImplInitContext ctx) {
    Scope s = symtab.getScope(ctx.getParent());
    PExp convention = currentTypeReprSym.getConvention();
    PExp correspondence = currentTypeReprSym.getCorrespondence();
    PExp typeInitEnsures = g.getTrueExp();
    List<ModuleParameterSymbol> moduleParamSyms = getAllModuleParameterSyms();

    VCAssertiveBlockBuilder block =
        new VCAssertiveBlockBuilder(g, s, "T_Init_Hypo=" + currentTypeReprSym.getName(), ctx)
            .assume(getModuleLevelAssertionsOfType(ClauseType.REQUIRES))
            .assume(
                getAssertionsFromModuleFormalParameters(
                    moduleParamSyms, this::extractAssumptionsFromParameter));

    assertiveBlocks.push(block);
  }
  @Override
  public void meet(Like node) throws RuntimeException {
    if (node.isCaseSensitive()) {
      optypes.push(ValueType.STRING);
      node.getArg().visit(this);
      optypes.pop();

      builder.append(" LIKE ");
      node.getPattern();
    } else {
      builder.append(
          parent
              .getDialect()
              .getILike(
                  new ValueExpressionEvaluator(node.getArg(), parent, ValueType.STRING).build(),
                  node.getOpPattern()));
    }
  }
Esempio n. 27
0
  public static QuantileDigest deserialize(DataInput input) {
    try {
      double maxError = input.readDouble();
      double alpha = input.readDouble();

      QuantileDigest result = new QuantileDigest(maxError, alpha);

      result.landmarkInSeconds = input.readLong();
      result.min = input.readLong();
      result.max = input.readLong();
      result.totalNodeCount = input.readInt();

      Deque<Node> stack = new ArrayDeque<>();
      for (int i = 0; i < result.totalNodeCount; i++) {
        int flags = input.readByte();

        Node node = deserializeNode(input);

        if ((flags & Flags.HAS_RIGHT) != 0) {
          node.right = stack.pop();
        }

        if ((flags & Flags.HAS_LEFT) != 0) {
          node.left = stack.pop();
        }

        stack.push(node);
        result.weightedCount += node.weightedCount;
        if (node.weightedCount >= ZERO_WEIGHT_THRESHOLD) {
          result.nonZeroNodeCount++;
        }
      }

      if (!stack.isEmpty()) {
        Preconditions.checkArgument(
            stack.size() == 1, "Tree is corrupted. Expected a single root node");
        result.root = stack.pop();
      }

      return result;
    } catch (IOException e) {
      throw Throwables.propagate(e);
    }
  }
Esempio n. 28
0
 private int findMaxArea(int[] height) {
   if (height == null || height.length == 0) return 0;
   int[] h = Arrays.copyOf(height, height.length + 1);
   int maxArea = 0;
   Deque<Integer> stack = new LinkedList();
   int k = 0;
   while (k < h.length) {
     if (stack.isEmpty() || h[stack.peek()] <= h[k]) {
       stack.push(k++);
     } else {
       int t = stack.pop();
       int leftIndex = (stack.isEmpty()) ? -1 : stack.peek();
       int rightIndex = k;
       int tmpArea = h[t] * (rightIndex - leftIndex - 1);
       maxArea = Math.max(maxArea, tmpArea);
     }
   }
   return maxArea;
 }
Esempio n. 29
0
  public void request(int i, int j) {
    if (i < 0 || i > versions.length || j < 0 || j > versions[i].length) return;
    if (versions[i][j] == 0) return;
    synchronized (nodeSubList) {
      for (OnDemandData onDemandData = (OnDemandData) nodeSubList.reverseGetFirst();
          onDemandData != null;
          onDemandData = (OnDemandData) nodeSubList.reverseGetNext())
        if (onDemandData.dataType == i && onDemandData.id == j) return;

      OnDemandData onDemandData_1 = new OnDemandData();
      onDemandData_1.dataType = i;
      onDemandData_1.id = j;
      onDemandData_1.incomplete = true;
      synchronized (aClass19_1370) {
        aClass19_1370.insertHead(onDemandData_1);
      }
      nodeSubList.push(onDemandData_1);
    }
  }
Esempio n. 30
0
 // 检测是否合法:合法 0,不合法 -1
 public int checkValid(String s) {
   Deque<Integer> q = new ArrayDeque<>();
   for (int i = 0; i < s.length(); i++) {
     char c = s.charAt(i);
     switch (c) {
       case '(':
         q.push(i);
         break;
       case ')':
         if (q.isEmpty()) {
           return -1;
         } else {
           q.pop();
         }
         break;
       default:
         break;
     }
   }
   return q.isEmpty() ? 0 : -1;
 }