Java Code Examples for java.util.Deque#pop()

The following examples show how to use java.util.Deque#pop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoleUtils.java    From keycloak with Apache License 2.0 6 votes vote down vote up
/**
 * Recursively expands composite roles into their composite.
 * @param role
 * @param visited Track roles, which were already visited. Those will be ignored and won't be added to the stream. Besides that,
 *                the "visited" set itself will be updated as a result of this method call and all the tracked roles will be added to it
 * @return Stream of containing all of the composite roles and their components.
 */
private static Stream<RoleModel> expandCompositeRolesStream(RoleModel role, Set<RoleModel> visited) {
    Stream.Builder<RoleModel> sb = Stream.builder();

    if (!visited.contains(role)) {
        Deque<RoleModel> stack = new ArrayDeque<>();
        stack.add(role);

        while (!stack.isEmpty()) {
            RoleModel current = stack.pop();
            sb.add(current);

            if (current.isComposite()) {
                current.getComposites().stream()
                        .filter(r -> !visited.contains(r))
                        .forEach(r -> {
                            visited.add(r);
                            stack.add(r);
                        });
            }
        }
    }

    return sb.build();
}
 
Example 2
Source File: CourseSchedule2.java    From LeetCode-Sol-Res with MIT License 6 votes vote down vote up
/**
 * Topological Sort. DFS.
 * Create a boolean array from visited state of each node.
 * Create a stack to store the result.
 * Then dfs each unvisited node.
 * Finally, convert the result to an integer array.
 */
private int[] dfs(int n, List<List<Integer>> adjs) {
  BitSet hasCycle = new BitSet(1); // Whether there is cycle in graph. Temporary mark.
  BitSet visited = new BitSet(adjs.size()); // Whether a node is visited. Permanent mark.
  BitSet onStack = new BitSet(adjs.size()); // Whether the node is on stack already during DFS.
  // DFS.
  Deque<Integer> stack = new ArrayDeque<>();
  for (int i = adjs.size() - 1; i >= 0; i--) {
    // Visit each unvisited node.
    if (!visited.get(i) && !hasOrder(i, adjs, visited, onStack, stack)) {
      return new int[0];
    }
  }
  // Convert stack result to int[].
  int[] res = new int[adjs.size()];
  for (int i = 0; !stack.isEmpty(); i++) {
    res[i] = stack.pop();
  }
  return res;
}
 
Example 3
Source File: BlockProcessor.java    From Box with Apache License 2.0 6 votes vote down vote up
private static void computeDominanceFrontier(MethodNode mth) {
	for (BlockNode exit : mth.getExitBlocks()) {
		exit.setDomFrontier(EMPTY);
	}
	List<BlockNode> domSortedBlocks = new ArrayList<>(mth.getBasicBlocks().size());
	Deque<BlockNode> stack = new LinkedList<>();
	stack.push(mth.getEnterBlock());
	while (!stack.isEmpty()) {
		BlockNode node = stack.pop();
		for (BlockNode dominated : node.getDominatesOn()) {
			stack.push(dominated);
		}
		domSortedBlocks.add(node);
	}
	Collections.reverse(domSortedBlocks);
	for (BlockNode block : domSortedBlocks) {
		try {
			computeBlockDF(mth, block);
		} catch (Exception e) {
			throw new JadxRuntimeException("Failed compute block dominance frontier", e);
		}
	}
}
 
Example 4
Source File: InvertBinaryTreeSolution.java    From yuzhouwan with Apache License 2.0 6 votes vote down vote up
static TreeNode invertTreeDFS(TreeNode root) {

        if (root == null) return null;

        final Deque<TreeNode> stack = new LinkedList<>();
        stack.push(root);

        while (!stack.isEmpty()) {
            final TreeNode node = stack.pop();
            final TreeNode left = node.left;
            node.left = node.right;
            node.right = left;

            if (node.left != null) {
                stack.push(node.left);
            }
            if (node.right != null) {
                stack.push(node.right);
            }
        }
        return root;
    }
 
Example 5
Source File: SwitchBlockSection.java    From Despector with MIT License 6 votes vote down vote up
@Override
public void appendTo(StatementBlock block, Locals locals, Deque<Instruction> stack) {
    Insn last = this.switchblock.getLast();
    this.switchblock.getOpcodes().remove(last);
    StatementBuilder.appendBlock(this.switchblock, block, locals, stack);
    this.switchblock.getOpcodes().add(last);
    Switch sswitch = new Switch(stack.pop());
    for (SwitchCaseBlockSection cs : this.cases) {
        StatementBlock body = new StatementBlock(StatementBlock.Type.SWITCH);
        Deque<Instruction> body_stack = new ArrayDeque<>();
        for (BlockSection body_section : cs.getBody()) {
            body_section.appendTo(body, locals, body_stack);
        }
        checkState(body_stack.isEmpty());
        sswitch.new Case(body, cs.doesBreak(), cs.isDefault(), cs.getTargets());
    }
    block.append(sswitch);
}
 
Example 6
Source File: Watermarker.java    From radon with GNU General Public License v3.0 6 votes vote down vote up
private static InsnList createInstructions(Deque<Character> watermark, int offset) {
    int xorKey = RandomUtils.getRandomInt();
    int watermarkChar = watermark.pop() ^ xorKey;
    int indexXorKey = RandomUtils.getRandomInt();
    int watermarkIndex = watermark.size() ^ indexXorKey;

    InsnList instructions = new InsnList();
    instructions.add(ASMUtils.getNumberInsn(xorKey));
    instructions.add(ASMUtils.getNumberInsn(watermarkChar));
    instructions.add(ASMUtils.getNumberInsn(indexXorKey));
    instructions.add(ASMUtils.getNumberInsn(watermarkIndex));

    // Local variable x where x is the max locals allowed in method can be the top of a long or double so we add 1
    instructions.add(new VarInsnNode(ISTORE, offset + 1));
    instructions.add(new VarInsnNode(ISTORE, offset + 2));
    instructions.add(new VarInsnNode(ISTORE, offset + 3));
    instructions.add(new VarInsnNode(ISTORE, offset + 4));

    return instructions;
}
 
Example 7
Source File: AbstractHistoryTree.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public @Nullable E getMatchingInterval(TimeRangeCondition timeCondition,
        Predicate<E> extraPredicate) {

    /* Queue a stack of nodes containing nodes intersecting t */
    Deque<Integer> queue = new LinkedList<>();
    /* We start by reading the information in the root node */
    queue.add(getRootNode().getSequenceNumber());

    /* Then we follow the down in the relevant children until we find the interval */
    try {
        while (!queue.isEmpty()) {
            int sequenceNumber = queue.pop();
            HTNode<E> currentNode = readNode(sequenceNumber);

            @Nullable E interval = currentNode.getMatchingInterval(timeCondition, extraPredicate);
            if (interval != null) {
                return interval;
            }

            if (currentNode.getNodeType() == HTNode.NodeType.CORE) {
                /* Here we add the relevant children nodes for BFS */
                queue.addAll(currentNode.selectNextChildren(timeCondition));
            }
        }
    } catch (ClosedChannelException e) {
    }
    return null;
}
 
Example 8
Source File: ModuleLayer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an ordered stream of layers. The first element is is this layer,
 * the remaining elements are the parent layers in DFS order.
 *
 * @implNote For now, the assumption is that the number of elements will
 * be very low and so this method does not use a specialized spliterator.
 */
Stream<ModuleLayer> layers() {
    List<ModuleLayer> allLayers = this.allLayers;
    if (allLayers != null)
        return allLayers.stream();

    allLayers = new ArrayList<>();
    Set<ModuleLayer> visited = new HashSet<>();
    Deque<ModuleLayer> stack = new ArrayDeque<>();
    visited.add(this);
    stack.push(this);

    while (!stack.isEmpty()) {
        ModuleLayer layer = stack.pop();
        allLayers.add(layer);

        // push in reverse order
        for (int i = layer.parents.size() - 1; i >= 0; i--) {
            ModuleLayer parent = layer.parents.get(i);
            if (!visited.contains(parent)) {
                visited.add(parent);
                stack.push(parent);
            }
        }
    }

    this.allLayers = allLayers = Collections.unmodifiableList(allLayers);
    return allLayers.stream();
}
 
Example 9
Source File: LogisticsRoute.java    From Logistics-Pipes-2 with MIT License 5 votes vote down vote up
public LogisticsRoute reverse() {
	Deque<EnumFacing> helpStack = this.directionStack;
	Deque<EnumFacing> reversedStack = new ArrayDeque<EnumFacing>();
	
	while(!helpStack.isEmpty()) {
		EnumFacing facing = helpStack.pop();
		facing = facing.getOpposite();
		reversedStack.push(facing);
	}
	
	return new LogisticsRoute(target, start, reversedStack, reversedStack.size(), isComplete);
}
 
Example 10
Source File: ExpressionReducer.java    From doma with Apache License 2.0 5 votes vote down vote up
protected ExpressionNode pop(OperatorNode node, Deque<ExpressionNode> p) {
  if (p.peek() == null) {
    ExpressionLocation location = node.getLocation();
    throw new ExpressionException(
        Message.DOMA3010, location.getExpression(), location.getPosition(), node.getExpression());
  }
  return p.pop();
}
 
Example 11
Source File: VoteTallyCache.java    From besu with Apache License 2.0 5 votes vote down vote up
private VoteTally constructMissingCacheEntries(
    final Deque<BlockHeader> headers, final VoteTally tally) {
  final VoteTally mutableVoteTally = tally.copy();
  while (!headers.isEmpty()) {
    final BlockHeader h = headers.pop();
    voteTallyUpdater.updateForBlock(h, mutableVoteTally);
    voteTallyCache.put(h.getHash(), mutableVoteTally.copy());
  }
  return mutableVoteTally;
}
 
Example 12
Source File: TemplateResolver.java    From poi-tl with Apache License 2.0 5 votes vote down vote up
private void resolveXWPFRuns(List<XWPFRun> runs, final List<MetaTemplate> metaTemplates,
        final Deque<BlockTemplate> stack) {
    for (XWPFRun run : runs) {
        String text = null;
        if (null == run || StringUtils.isBlank(text = run.getText(0))) continue;
        RunTemplate runTemplate = parseTemplateFactory(text, run);
        if (null == runTemplate) continue;
        char charValue = runTemplate.getSign().charValue();
        if (charValue == config.getIterable().getLeft()) {
            IterableTemplate freshIterableTemplate = new IterableTemplate(runTemplate);
            stack.push(freshIterableTemplate);
        } else if (charValue == config.getIterable().getRight()) {
            if (stack.isEmpty()) throw new ResolverException(
                    "Mismatched start/end tags: No start mark found for end mark " + runTemplate);
            BlockTemplate latestIterableTemplate = stack.pop();
            if (StringUtils.isNotEmpty(runTemplate.getTagName())
                    && !latestIterableTemplate.getStartMark().getTagName().equals(runTemplate.getTagName())) {
                throw new ResolverException("Mismatched start/end tags: start mark "
                        + latestIterableTemplate.getStartMark() + " does not match to end mark " + runTemplate);
            }
            latestIterableTemplate.setEndMark(runTemplate);
            if (latestIterableTemplate instanceof IterableTemplate) {
                latestIterableTemplate = ((IterableTemplate) latestIterableTemplate).buildIfInline();
            }
            if (stack.isEmpty()) {
                metaTemplates.add(latestIterableTemplate);
            } else {
                stack.peek().getTemplates().add(latestIterableTemplate);
            }
        } else {
            if (stack.isEmpty()) {
                metaTemplates.add(runTemplate);
            } else {
                stack.peek().getTemplates().add(runTemplate);
            }
        }
    }
}
 
Example 13
Source File: EvaluateReversePolish.java    From LeetCode-Sol-Res with MIT License 5 votes vote down vote up
/**
 * Stack.
 * Suppose all reverse polish are valid.
 * For each token t in tokens:
 * | If t is an operator:
 * |   Pop two numbers and do the calculation.
 * |   Push result onto the stack.
 * | Else t should be a number:
 * |   Just push t onto the stack.
 * Return the top value of stack as the result.
 */
public int evalRPN(String[] tokens) {
  if (tokens == null || tokens.length == 0) {
    return 0;
  }
  Deque<Integer> s = new ArrayDeque<>();
  for (int i = 0; i < tokens.length; i++) {
    switch (tokens[i]) {
      case "+":
        s.push(s.pop() + s.pop());
        break;
      case "-":
        s.push(-s.pop() + s.pop());
        break;
      case "*":
        s.push(s.pop() * s.pop());
        break;
      case "/":
        int num1 = s.pop();
        int num2 = s.pop();
        s.push(num2 / num1);
        break;
      default:
        s.push(Integer.valueOf(tokens[i]));
        break;
    }
  }
  return s.isEmpty() ? 0 : s.peek();
}
 
Example 14
Source File: FileListFactory.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculates all files contained in the given reference point and adds them to the given file
 * list. Returns a list of all found files.
 *
 * @param list the file list
 * @param referencePoint the reference point for which to calculate the members
 * @return a list of all found files
 * @throws IOException if the members contained in the reference point or one of its folders or
 *     the charset of a contained file could not be obtained
 */
private static List<IFile> calculateMembers(
    final FileList list, final IReferencePoint referencePoint) throws IOException {

  List<IResource> resources = referencePoint.members();

  if (resources.isEmpty()) return Collections.emptyList();

  Deque<IResource> stack = new LinkedList<>(resources);

  List<IFile> files = new LinkedList<>();

  while (!stack.isEmpty()) {
    IResource resource = stack.pop();

    if (resource.isIgnored() || !resource.exists()) continue;

    String path = resource.getReferencePointRelativePath().toPortableString();

    if (list.contains(path)) continue;

    switch (resource.getType()) {
      case FILE:
        files.add((IFile) resource);
        MetaData data = new MetaData();
        list.addPath(path, data, false);
        list.addEncoding(((IFile) resource).getCharset());
        break;

      case FOLDER:
        stack.addAll(((IFolder) resource).members());
        list.addPath(path, null, true);
        break;
    }
  }

  return files;
}
 
Example 15
Source File: ElvisBlockSection.java    From Despector with MIT License 5 votes vote down vote up
@Override
public void appendTo(StatementBlock block, Locals locals, Deque<Instruction> stack) {
    // The blocksection before this one should have been our processed elvis
    // and will have left the value to be null checked on the stack
    StatementBlock dummy = new StatementBlock(StatementBlock.Type.IF);
    Deque<Instruction> dummy_stack = new ArrayDeque<>();
    StatementBuilder.appendBlock(this.block, dummy, locals, dummy_stack);
    checkState(dummy_stack.size() == 1);
    Elvis elvis = new Elvis(stack.pop(), dummy_stack.pop());
    stack.push(elvis);
}
 
Example 16
Source File: SpliteratorTestHelper.java    From streamsupport with GNU General Public License v2.0 4 votes vote down vote up
private static <T> void testSplitUntilNull(SplitNode<T> e) {
    // Use an explicit stack to avoid a StackOverflowException when testing a Spliterator
    // that when repeatedly split produces a right-balanced (and maybe degenerate) tree, or
    // for a spliterator that is badly behaved.
    Deque<SplitNode<T>> stack = new ArrayDeque<>();
    stack.push(e);

    int iteration = 0;
    while (!stack.isEmpty()) {
        assertTrue(iteration++ < MAXIMUM_STACK_CAPACITY, "Exceeded maximum stack modification count of 1 << 18");

        e = stack.pop();
        Spliterator<T> parentAndRightSplit = e.s;

        long parentEstimateSize = parentAndRightSplit.estimateSize();
        assertTrue(parentEstimateSize >= 0,
                   String.format("Split size estimate %d < 0", parentEstimateSize));

        long parentSize = parentAndRightSplit.getExactSizeIfKnown();
        Spliterator<T> leftSplit = parentAndRightSplit.trySplit();
        if (leftSplit == null) {
            parentAndRightSplit.forEachRemaining(e.c);
            continue;
        }

        assertSpliterator(leftSplit, e.rootCharacteristics);
        assertSpliterator(parentAndRightSplit, e.rootCharacteristics);

        if (parentEstimateSize != Long.MAX_VALUE && leftSplit.estimateSize() > 0
            && parentAndRightSplit.estimateSize() > 0) {
            assertTrue(leftSplit.estimateSize() < parentEstimateSize,
                       String.format("Left split size estimate %d >= parent split size estimate %d",
                                     leftSplit.estimateSize(), parentEstimateSize));
            assertTrue(parentAndRightSplit.estimateSize() < parentEstimateSize,
                       String.format("Right split size estimate %d >= parent split size estimate %d",
                                     leftSplit.estimateSize(), parentEstimateSize));
        }
        else {
            assertTrue(leftSplit.estimateSize() <= parentEstimateSize,
                       String.format("Left split size estimate %d > parent split size estimate %d",
                                     leftSplit.estimateSize(), parentEstimateSize));
            assertTrue(parentAndRightSplit.estimateSize() <= parentEstimateSize,
                       String.format("Right split size estimate %d > parent split size estimate %d",
                                     leftSplit.estimateSize(), parentEstimateSize));
        }

        long leftSize = leftSplit.getExactSizeIfKnown();
        long rightSize = parentAndRightSplit.getExactSizeIfKnown();
        if (parentSize >= 0 && leftSize >= 0 && rightSize >= 0)
            assertEquals(parentSize, leftSize + rightSize,
                         String.format("exact left split size %d + exact right split size %d != parent exact split size %d",
                                       leftSize, rightSize, parentSize));

        // Add right side to stack first so left side is popped off first
        stack.push(e.fromSplit(parentAndRightSplit));
        stack.push(e.fromSplit(leftSplit));
    }
}
 
Example 17
Source File: JobServiceImpl.java    From herd with Apache License 2.0 4 votes vote down vote up
@Override
public Job deleteJob(String jobId, JobDeleteRequest jobDeleteRequest) throws Exception
{
    Assert.hasText(jobId, "jobId must be specified");
    Assert.notNull(jobDeleteRequest, "jobDeleteRequest must be specified");
    Assert.hasText(jobDeleteRequest.getDeleteReason(), "deleteReason must be specified");

    // Trim input parameters.
    String localJobId = jobId.trim();

    ProcessInstance mainProcessInstance = activitiService.getProcessInstanceById(localJobId);

    if (mainProcessInstance != null)
    {
        checkPermissions(mainProcessInstance.getProcessDefinitionKey(), new NamespacePermissionEnum[] {NamespacePermissionEnum.EXECUTE});

        // Load all processes (main process and sub-processes) into a deque to be later deleted.
        Deque<String> processInstanceIds = new ArrayDeque<>();
        processInstanceIds.push(mainProcessInstance.getProcessInstanceId());
        Deque<String> superProcessInstanceIds = new ArrayDeque<>();
        superProcessInstanceIds.push(mainProcessInstance.getProcessInstanceId());
        while (!superProcessInstanceIds.isEmpty())
        {
            String superProcessInstanceId = superProcessInstanceIds.pop();

            // Get all executions with the parent id equal to the super process instance id.
            for (Execution execution : activitiRuntimeService.createExecutionQuery().parentId(superProcessInstanceId).list())
            {
                processInstanceIds.push(execution.getId());
            }

            // Get all active sub-processes for the super process instance id.
            for (ProcessInstance subProcessInstance : activitiRuntimeService.createProcessInstanceQuery().superProcessInstanceId(superProcessInstanceId)
                .active().list())
            {
                processInstanceIds.push(subProcessInstance.getId());
                superProcessInstanceIds.push(subProcessInstance.getId());
            }
        }

        // Delete all processes individually in LIFO order.
        while (!processInstanceIds.isEmpty())
        {
            activitiService.deleteProcessInstance(processInstanceIds.pop(), jobDeleteRequest.getDeleteReason());
        }
    }
    else
    {
        throw new ObjectNotFoundException(String.format("Job with ID \"%s\" does not exist or is already completed.", localJobId));
    }

    return getJob(localJobId, false, false);
}
 
Example 18
Source File: JexlASTHelper.java    From datawave with Apache License 2.0 4 votes vote down vote up
/**
 * Checks to see if the tree contains any null children, children with null parents, or children with conflicting parentage.
 *
 * @param rootNode
 *            the tree to validate
 * @param failHard
 *            whether or not to throw an exception if validation fails
 * @return true if valid, false otherwise
 */
// checks to see if the tree contains any null children, children with null parents, or children with conflicting parentage
public static boolean validateLineage(JexlNode rootNode, boolean failHard) {
    boolean result = true;
    
    // add all the nodes to the stack and iterate...
    Deque<JexlNode> workingStack = new LinkedList<>();
    workingStack.push(rootNode);
    
    // go through all of the nodes from parent to children, and ensure that parent and child relationships are correct
    while (!workingStack.isEmpty()) {
        JexlNode node = workingStack.pop();
        
        if (node.jjtGetNumChildren() > 0) {
            for (JexlNode child : children(node)) {
                if (child != null) {
                    if (child.jjtGetParent() == null) {
                        if (failHard)
                            throw new RuntimeException("Failed to validate lineage: Tree included a child with a null parent.");
                        else
                            log.error("Failed to validate lineage: Tree included a child with a null parent.");
                        
                        result = false;
                    } else if (child.jjtGetParent() != node) {
                        if (failHard)
                            throw new RuntimeException("Failed to validate lineage:  Included a child with a conflicting parent.");
                        else
                            log.error("Failed to validate lineage:  Included a child with a conflicting parent.");
                        
                        result = false;
                    }
                    workingStack.push(child);
                } else {
                    if (failHard)
                        throw new RuntimeException("Failed to validate lineage: Included a null child.");
                    else
                        log.error("Failed to validate lineage: Included a null child.");
                    
                    result = false;
                }
            }
        }
    }
    return result;
}
 
Example 19
Source File: SpliteratorCollisions.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static <T> void testSplitUntilNull(SplitNode<T> e) {
    // Use an explicit stack to avoid a StackOverflowException when testing a Spliterator
    // that when repeatedly split produces a right-balanced (and maybe degenerate) tree, or
    // for a spliterator that is badly behaved.
    Deque<SplitNode<T>> stack = new ArrayDeque<>();
    stack.push(e);

    int iteration = 0;
    while (!stack.isEmpty()) {
        assertTrue(iteration++ < MAXIMUM_STACK_CAPACITY, "Exceeded maximum stack modification count of 1 << 18");

        e = stack.pop();
        Spliterator<T> parentAndRightSplit = e.s;

        long parentEstimateSize = parentAndRightSplit.estimateSize();
        assertTrue(parentEstimateSize >= 0,
                   String.format("Split size estimate %d < 0", parentEstimateSize));

        long parentSize = parentAndRightSplit.getExactSizeIfKnown();
        Spliterator<T> leftSplit = parentAndRightSplit.trySplit();
        if (leftSplit == null) {
            parentAndRightSplit.forEachRemaining(e.c);
            continue;
        }

        assertSpliterator(leftSplit, e.rootCharacteristics);
        assertSpliterator(parentAndRightSplit, e.rootCharacteristics);

        if (parentEstimateSize != Long.MAX_VALUE && leftSplit.estimateSize() > 0 && parentAndRightSplit.estimateSize() > 0) {
            assertTrue(leftSplit.estimateSize() < parentEstimateSize,
                       String.format("Left split size estimate %d >= parent split size estimate %d", leftSplit.estimateSize(), parentEstimateSize));
            assertTrue(parentAndRightSplit.estimateSize() < parentEstimateSize,
                       String.format("Right split size estimate %d >= parent split size estimate %d", leftSplit.estimateSize(), parentEstimateSize));
        }
        else {
            assertTrue(leftSplit.estimateSize() <= parentEstimateSize,
                       String.format("Left split size estimate %d > parent split size estimate %d", leftSplit.estimateSize(), parentEstimateSize));
            assertTrue(parentAndRightSplit.estimateSize() <= parentEstimateSize,
                       String.format("Right split size estimate %d > parent split size estimate %d", leftSplit.estimateSize(), parentEstimateSize));
        }

        long leftSize = leftSplit.getExactSizeIfKnown();
        long rightSize = parentAndRightSplit.getExactSizeIfKnown();
        if (parentSize >= 0 && leftSize >= 0 && rightSize >= 0)
            assertEquals(parentSize, leftSize + rightSize,
                         String.format("exact left split size %d + exact right split size %d != parent exact split size %d",
                                       leftSize, rightSize, parentSize));

        // Add right side to stack first so left side is popped off first
        stack.push(e.fromSplit(parentAndRightSplit));
        stack.push(e.fromSplit(leftSplit));
    }
}
 
Example 20
Source File: PostfixFunctionParser.java    From big-math with MIT License 3 votes vote down vote up
@Override
public BigDecimal apply(BigDecimal value, MathContext mathContext) {
	Deque<BigDecimal> stack = new ArrayDeque<>();

	stack.push(value);
	
	executeScript(mathContext, stack);

	return stack.pop();
}