/** * Method to find the Euler Tour based on the Hierholzer's algorithm. * * @param g : Input graph for which the tour is to be found. * @return : Returns a list of edges that comprises of the Euler Tour. */ public static List<Edge> findEulerTour(Graph<Vertex> g) { Vertex start = g.verts.get(1); Stack<Edge> forward = new Stack<Edge>(); Stack<Edge> backtrack = new Stack<Edge>(); Edge e = getUnvisitedEdge(start); while (e != null) { e.visited = true; forward.push(e); e = getUnvisitedEdge(e.To); } while (!(forward.isEmpty())) { e = forward.pop(); backtrack.push(e); e = getUnvisitedEdge(e.From); while (e != null) { e.visited = true; forward.push(e); e = getUnvisitedEdge(e.To); } } List<Edge> path = new LinkedList<Edge>(); while (!backtrack.isEmpty()) { Edge edge = backtrack.pop(); path.add(edge); } return path; }
private String getCorrectFolderName(int folderIndex) { StringTokenizer stok = new StringTokenizer(firstAddressParentStr, "/"); Stack<String> stack = new Stack<String>(); while (stok.hasMoreTokens()) stack.push(stok.nextToken()); for (int i = 1; i < folderIndex; i++) stack.pop(); return stack.pop(); }
public static int calculate(String postfixExpression) { if (postfixExpression == null) throw new IllegalArgumentException("postfixExpression can't be null"); char[] a = postfixExpression.toCharArray(); int N = a.length; Stack<Integer> s = new Stack<>(); for (int i = 0; i < N; i++) { if (a[i] == '+') { s.push(s.pop() + s.pop()); } if (a[i] == '*') { s.push(s.pop() * s.pop()); } if (a[i] == '-') { Integer subtrahend = s.pop(); Integer minuend = s.pop(); s.push(minuend - subtrahend); } if (a[i] == '/') { Integer divisor = s.pop(); Integer quotient = s.pop(); s.push(quotient / divisor); } if ((a[i] >= '0') && (a[i] <= '9')) { s.push(0); } while ((a[i] >= '0') && (a[i] <= '9')) { s.push(10 * s.pop() + (a[i++] - '0')); } } return (s.size() != 0) ? s.pop() : 0; }
public static boolean adverbial_Particle(Stack s) { byte[] topElmt = ((Entry) s.peek()).getPart(); byte[] oldTopElmt = topElmt; // kayil if (ByteMeth.endsWith(topElmt, Constant.kayil)) { // clia.unl.unicode.utils.Utils.printOut(Analyser.print, x + "kayil"); s.pop(); s.push(new Entry(Constant.kayil, Tag.ParticleSuffix)); // change topElmt = ByteMeth.subArray(topElmt, 0, topElmt.length - Constant.kayil.length); s.push(new Entry(topElmt, -1, oldTopElmt)); Sandhi.k(s); return true; } // poothu if (ByteMeth.endsWith(topElmt, Constant.poothu)) { // clia.unl.unicode.utils.Utils.printOut(Analyser.print, x + "poothu"); s.pop(); s.push(new Entry(Constant.poothu, Tag.ParticleSuffix)); // change topElmt = ByteMeth.subArray(topElmt, 0, topElmt.length - Constant.poothu.length); s.push(new Entry(topElmt, -1, oldTopElmt)); Sandhi.k(s); return true; } return false; }
/** * Test method for {@link org.insa.megaupload.utils.Algo#PCC(org.insa.megaupload.entities.Carte, * org.insa.megaupload.entities.Lieu, org.insa.megaupload.entities.Lieu)} . */ @Test public void testPCC() { Stack<Trajet> t = Algo.PCC(this.carte, carte.getA(), carte.getE()); assertTrue( "", t.peek().getDepart().getNom().equals("A") || t.peek().getArrivee().getNom().equals("A")); assertTrue( "", t.peek().getDepart().getNom().equals("C") || t.peek().getArrivee().getNom().equals("C")); t.pop(); assertTrue( "", t.peek().getDepart().getNom().equals("C") || t.peek().getArrivee().getNom().equals("C")); assertTrue( "", t.peek().getDepart().getNom().equals("B") || t.peek().getArrivee().getNom().equals("B")); t.pop(); assertTrue( "", t.peek().getDepart().getNom().equals("B") || t.peek().getArrivee().getNom().equals("B")); assertTrue( "", t.peek().getDepart().getNom().equals("E") || t.peek().getArrivee().getNom().equals("E")); t.pop(); }
public int calculate(String s) { Stack<Integer> stack = new Stack<Integer>(); int num = 0; char sign = '+'; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (Character.isDigit(c)) { num = num * 10 + (c - '0'); } if (i == s.length() - 1 || !Character.isDigit(c) && c != ' ') { switch (sign) { case '+': stack.push(+num); break; case '-': stack.push(-num); break; case '*': stack.push(stack.pop() * num); break; case '/': stack.push(stack.pop() / num); break; } sign = c; num = 0; } } int result = 0; while (!stack.isEmpty()) result += stack.pop(); return result; }
private boolean contains2Words(Stack<String> stack) { String list_start = stack.pop(); // could be a LIST_START String word1 = stack.pop(); // token to analyze if (!stack.isEmpty()) { String word2 = stack.pop(); // token to analyze if (!stack.isEmpty() && stack.peek().equals(LIST_START)) { stack.push(word2); stack.push(word1); stack.push(list_start); if (isWord(word1) && isWord(word2)) { printOut("Contains TWO WORDS"); return true; } else { return false; } } else { stack.push(word2); stack.push(word1); stack.push(list_start); return false; } } stack.push(word1); stack.push(list_start); return false; }
@Override public void exitUncertainDate(UncertainDateContext ctx) { if (ctx.exception != null) return; Date latestDate = (Date) stack.pop(); Date earliestDate = (Date) stack.pop(); int earliestInterval = DateUtils.getCircaIntervalYears(earliestDate.getYear(), earliestDate.getEra()); int latestInterval = DateUtils.getCircaIntervalYears(latestDate.getYear(), latestDate.getEra()); // Express the circa interval as a qualifier. // stack.push(earliestDate.withQualifier(QualifierType.MINUS, earliestInterval, // QualifierUnit.YEARS)); // stack.push(latestDate.withQualifier(QualifierType.PLUS, latestInterval, // QualifierUnit.YEARS)); // OR: // Express the circa interval as an offset calculated into the year. DateUtils.subtractYears(earliestDate, earliestInterval); DateUtils.addYears(latestDate, latestInterval); stack.push(earliestDate); stack.push(latestDate); }
@Override public void exitCertainDate(CertainDateContext ctx) { if (ctx.exception != null) return; Date latestDate = (Date) stack.pop(); Date earliestDate = (Date) stack.pop(); // Set null eras to the default. if (earliestDate.getEra() == null) { earliestDate.setEra(Date.DEFAULT_ERA); } if (latestDate.getEra() == null) { latestDate.setEra(Date.DEFAULT_ERA); } // Finalize any deferred calculations. if (latestDate instanceof DeferredDate) { ((DeferredDate) latestDate).resolveDate(); } if (earliestDate instanceof DeferredDate) { ((DeferredDate) earliestDate).resolveDate(); } stack.push(earliestDate); stack.push(latestDate); }
public static int calculate(String s) { // 使用栈来计算表达式的值 if (s == null || s.length() == 0) return 0; Stack<Integer> stack = new Stack<Integer>(); // 只有在遇到 () 时才会用到栈 int ans = 0; // 用来存放当前计算的结果 int sign = 1; // 用来存放下一个运算的符号 for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); // 拿出字符 if (Character.isDigit(c)) { // 如果是数字 int cur = c - '0'; while (i + 1 < s.length() && Character.isDigit(s.charAt(i + 1))) { cur = 10 * cur + s.charAt(++i) - '0'; } // 把数字拼凑完成 ans += sign * cur; // 计算下结果 } else if (c == '-') { sign = -1; // 下一次做- } else if (c == '+') { sign = 1; // 下一次做+ } else if (c == '(') { // 如果是( stack.push(ans); // 则把 结果 和 运算符号一起入栈,ans sign重置 ans = 0; // 必须,不然括号里第一个数字立即运算了 stack.push(sign); sign = 1; // 必须,不然括号里第一个数字之前的符号不确定 } else if (c == ')') { // 如果是) ans = stack.pop() * ans + stack.pop(); // 则把 运算符 和 结果一起出栈, 计算当前的结果 } } return ans; }
public synchronized void unpack(ISOComponent c, InputStream in) throws ISOException, IOException { LogEvent evt = new LogEvent(this, "unpack"); try { if (!(c instanceof ISOMsg)) throw new ISOException("Can't call packager on non Composite"); while (!stk.empty()) // purge from possible previous error stk.pop(); reader.parse(new InputSource(in)); if (stk.empty()) throw new ISOException("error parsing"); ISOMsg m = (ISOMsg) c; m.merge((ISOMsg) stk.pop()); if (logger != null) evt.addMessage(m); } catch (ISOException e) { evt.addMessage(e); throw e; } catch (SAXException e) { evt.addMessage(e); throw new ISOException(e.toString()); } finally { Logger.log(evt); } }
// Using two stacks to simulate the inorder traversal with two pointers solution. // Time complexity O(n). // Space complexity O(logn) (height of tree) public static void twoSum(TreeNode root, int target) { // The idea behind this is similar to find two sum in a sorted array. // Using two stacks to store the left track of nodes and right track of node. Stack<TreeNode> leftStack = new Stack<TreeNode>(), rightStack = new Stack<TreeNode>(); TreeNode scan, leftElem, rightElem; populateRight(root, rightStack); populateLeft(root, leftStack); while (leftStack.peek().val < rightStack.peek().val) { // exits when root.val == root.val if (leftStack.peek().val + rightStack.peek().val > target) { // cur sum larger than target. // reduce the tail(rightStack) rightElem = rightStack.pop(); if (rightElem.left != null) { // Push the left child of cur node and all of its right children to stack. for (scan = rightElem.left; scan != null; scan = scan.right) { rightStack.add(scan); } } } else if (leftStack.peek().val + rightStack.peek().val < target) { leftElem = leftStack.pop(); if (leftElem.right != null) { for (scan = leftElem.right; scan != null; scan = scan.left) { leftStack.add(scan); } } } else { System.out.println( String.format("%d + %d = %d", leftStack.peek().val, rightStack.peek().val, target)); populateLeft(leftStack.pop().right, leftStack); populateRight(rightStack.pop().left, rightStack); } } }
public void sort() { if (stack.isEmpty()) { return; } helper.push(stack.pop()); boolean sorted = false; while (!sorted) { while (!stack.isEmpty() && stack.peek() > helper.peek()) { helper.push(stack.pop()); if (stack.isEmpty()) { while (!helper.isEmpty()) { stack.push(helper.pop()); } sorted = true; break; } } if (!sorted) { int temp = stack.pop(); while (!helper.isEmpty() && helper.peek() > temp) { stack.push(helper.pop()); } helper.push(temp); } } }
/** * This is the reduce implementation * * @param rule the rule to reduce by */ private void reduce(int rule) throws SyntaxError { // get the rule number to reduce by int num = Math.abs(rule); // this section is for generating code if (num == 27 || num == 28 || num == 29 || num == 30 || num == 31 || num == 32 || num == 33 || num == 37 || num == 39 || num == 41) { gen.reduce(num); } // popping empty from the stack, just push if (GrammarTable.grammar[num].length != 1) { // start popping and matching stuff int input = 0; for (int i = GrammarTable.grammar[num].length - 1; i > 0; i--) { stack.pop(); input = stack.pop(); if (GrammarTable.grammar[num][i] == input) { continue; } else { throw new SyntaxError("Syntax error in source file on line " + scanner.getLine()); } } } // push the LHS curState = stack.peek(); // push the left hand side stack.push(GrammarTable.getRule(num)[0]); curState = pTable.getNextState(curState, GrammarTable.getRule(num)[0]); stack.push(curState); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.back: prevId.pop(); prevPath.pop(); String present_path = prevPath.elementAt(prevPath.size() - 1); if (present_path.equalsIgnoreCase("HOME")) back.setEnabled(false); else back.setEnabled(true); int present_id = prevId.elementAt(prevId.size() - 1); Log.i("id", "" + present_id); Log.i("path", present_path); ArrayList<SearchResults> Results = getData(String.valueOf(present_id)); adapt = new MyCustomBaseAdapter(SkydriveFolderList.this, Results); lv.setAdapter(adapt); adapt.notifyDataSetChanged(); path.setText(present_path); break; case R.id.search: // getResult(et.getText().toString()); break; } // TODO Auto-generated method stub }
@Override public void exitHyphenatedRange(HyphenatedRangeContext ctx) { if (ctx.exception != null) return; Date latestEndDate = (Date) stack.pop(); stack.pop(); // latestStartDate stack.pop(); // earliestEndDate Date earliestStartDate = (Date) stack.pop(); // If no era was explicitly specified for the first date, // make it inherit the era of the second date. if (earliestStartDate.getEra() == null && latestEndDate.getEra() != null) { earliestStartDate.setEra(latestEndDate.getEra()); } // Finalize any deferred calculations. if (earliestStartDate instanceof DeferredDate) { ((DeferredDate) earliestStartDate).resolveDate(); } if (latestEndDate instanceof DeferredDate) { ((DeferredDate) latestEndDate).resolveDate(); } stack.push(earliestStartDate); stack.push(latestEndDate); }
public static boolean isBalanced(String s) { Stack<Character> stack = new Stack<Character>(); for (int i = 0; i < s.length(); ++i) { char c = s.charAt(i); if (c == '{' || c == '[' || c == '(') stack.push(c); else if (c == '}') { if (!stack.isEmpty() && stack.peek() == '{') { stack.pop(); } else return false; } else if (c == ']') { if (!stack.isEmpty() && stack.peek() == '[') { stack.pop(); } else return false; } else if (c == ')') { if (!stack.isEmpty() && stack.peek() == '(') { stack.pop(); } else return false; } else { } } return stack.isEmpty(); }
@Override public void exitNthCenturyRange(NthCenturyRangeContext ctx) { if (ctx.exception != null) return; Era era = (Era) stack.pop(); Integer endN = (Integer) stack.pop(); Part endPart = (Part) stack.pop(); Integer startN = (Integer) stack.pop(); Part startPart = (Part) stack.pop(); if (era == null) { era = Date.DEFAULT_ERA; } int startYear = DateUtils.nthCenturyToYear(startN); int endYear = DateUtils.nthCenturyToYear(endN); stack.push( startPart == null ? DateUtils.getCenturyStartDate(startYear, era) : DateUtils.getPartialCenturyStartDate(startYear, startPart, era)); stack.push( startPart == null ? DateUtils.getCenturyEndDate(startYear, era) : DateUtils.getPartialCenturyEndDate(startYear, startPart, era)); stack.push( endPart == null ? DateUtils.getCenturyStartDate(endYear, era) : DateUtils.getPartialCenturyStartDate(endYear, endPart, era)); stack.push( endPart == null ? DateUtils.getCenturyEndDate(endYear, era) : DateUtils.getPartialCenturyEndDate(endYear, endPart, era)); }
public boolean isValid(String s) { if (s == null || s.length() == 0) return true; Stack<Character> stack = new Stack<Character>(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '(': case '[': case '{': stack.push(c); break; case ')': if (!stack.isEmpty() && stack.peek() == '(') stack.pop(); else return false; break; case ']': if (!stack.isEmpty() && stack.peek() == '[') stack.pop(); else return false; break; case '}': if (!stack.isEmpty() && stack.peek() == '{') stack.pop(); else return false; break; default: return false; } } return stack.isEmpty(); }
@Override public void exitMillennium(MillenniumContext ctx) { if (ctx.exception != null) return; Era era = (Era) stack.pop(); Integer n = (Integer) stack.pop(); if (era != null) { // If the era was explicitly specified, the start and end years // may be calculated now. stack.push(DateUtils.getMillenniumStartDate(n, era)); stack.push(DateUtils.getMillenniumEndDate(n, era)); } else { // If the era was not explicitly specified, the start and end years // can't be calculated yet. The calculation must be deferred until // later. For example, this millennium may be the start of a hyphenated // range, where the era will be inherited from the era of the end of // the range; this era won't be known until farther up the parse tree, // when both sides of the range will have been parsed. stack.push(new DeferredMillenniumStartDate(n)); stack.push(new DeferredMillenniumEndDate(n)); } }
@Override public int leave(IASTStatement statement) { try { if ((statement instanceof IASTSwitchStatement) || (statement instanceof IASTForStatement) || (statement instanceof IASTWhileStatement) || (statement instanceof IASTDoStatement)) { ScopeInfo scope; if (statement instanceof IASTSwitchStatement) { scope = _scopeStack.peek(); if ((scope._statement instanceof IASTCaseStatement) || (scope._statement instanceof IASTDefaultStatement)) { _scopeStack.pop(); } } scope = _scopeStack.pop(); if (!scope._statement.getClass().equals(statement.getClass())) { if (Activator.DEBUG) { Activator.log( "Lost track of scope. Expected:" + scope._statement + //$NON-NLS-1$ " but was:" + statement); //$NON-NLS-1$ } } } } catch (EmptyStackException e) { if (Activator.DEBUG) Activator.log(e); } return super.leave(statement); }
private void removeStackObj() throws XMLStreamException { if (!stackObj.empty()) { if (topNestedArrayObj == null) { stackObj.pop(); } else { if (stackObj.peek().equals(topNestedArrayObj)) { topNestedArrayObj = null; processedJsonObject.clear(); stackObj.pop(); } else { processedJsonObject.push(stackObj.pop()); } } if (!stackObj.empty()) { localName = stackObj.peek().getName(); } else { localName = ""; } } else { System.out.println("stackObj is empty"); throw new XMLStreamException( "Error while processing input JSON stream, JSON request may not valid ," + " it may has more end object characters "); } }
public static int decode(String chromosome) { Stack<Integer> bits = new Stack<Integer>(); for (int i = 0; i <= chromosome.length() - 4; i += 4) { String gene = chromosome.substring(i, i + 4); int geneIndex = Integer.parseInt(gene, 2); if (geneIndex >= genes.length) { // skip this "gene" we don"t know what to do with it continue; } else if (geneIndex < 10) { // Add the number to the stack bits.push(Integer.parseInt(genes[geneIndex])); } else { // Do simple arithmatic operation int a = bits.pop(); int b = bits.pop(); if (genes[geneIndex].equals("+")) { bits.push(a + b); } else if (genes[geneIndex].equals("-")) { bits.push(a - b); } else if (genes[geneIndex].equals("*")) { bits.push(a * b); } else if (genes[geneIndex].equals("/")) { bits.push(a / b); } } } return bits.pop(); }
/** * Parse a string delimited by comma into a list of object instances depending on * * <pre>itemParser</pre> * * . * * @param str String delimited by comma * @param itemParser A function to transform a string to an object. * @param <T> Type to be transformed from a string * @return List of object instances */ static <T> List<T> parseList(String str, Function<String, T> itemParser) { if (!str.contains(",")) { // if just one item return ImmutableList.of(itemParser.apply(str)); } final ImmutableList.Builder<T> fields = ImmutableList.builder(); final Stack<Character> stack = new Stack<>(); int paramStartIdx = 0; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c == '<' || c == '[' || c == '(') { stack.push(c); } else if (c == '>') { Assert.assertCondition(stack.pop() == '<', "Bad signature: '%s'", str); } else if (c == ']') { Assert.assertCondition(stack.pop() == '[', "Bad signature: '%s'", str); } else if (c == ')') { Assert.assertCondition(stack.pop() == '(', "Bad signature: '%s'", str); } else if (c == ',') { if (stack.isEmpty()) { // ensure outermost type parameters fields.add(itemParser.apply(str.substring(paramStartIdx, i))); paramStartIdx = i + 1; } } } Assert.assertCondition(stack.empty(), "Bad signature: '%s'", str); if (paramStartIdx < str.length()) { fields.add(itemParser.apply(str.substring(paramStartIdx, str.length()))); } return fields.build(); }
public Geometry run() throws ProofFailureException { if (!geometries.isEmpty()) { try { init(); Operation operator; Geometry rhs = geometries .pop(); // the far rhs of the geometry / the basis of the OperationalGeometry. Order // Shouldn't matter though while (!running_geometries.isEmpty()) { rhs = running_geometries.pop(); if (!running_operations.isEmpty()) { operator = running_operations.pop(); Geometry lhs = running_geometries.pop(); Action a = actions.get(operator); rhs = a.act(lhs, rhs); } else throw new ProofFailureException("INTERNAL: Mismatched Operator and Geometry Tables"); } flush(); return rhs; } catch (GeometricFailure e) { throw new ProofFailureException("Inter"); } } else throw new ProofFailureException("INTERNAL: This Machine Contains No Geometry."); }
/** * Make a field from a string representation * * @param str String * @return Field */ static Field parseField(String str) { // A field consists of an identifier and a type, and they are delimited by space. if (!str.contains(" ")) { Assert.assertCondition(false, "Bad field signature: '%s'", str); } // Stack to track the nested bracket depth Stack<Character> stack = new Stack<>(); int paramStartIdx = 0; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c == '<' || c == '[' || c == '(') { stack.push(c); } else if (c == '>') { // for validation Assert.assertCondition(stack.pop() == '<', "Bad field signature: '%s'", str); } else if (c == ']') { // for validation Assert.assertCondition(stack.pop() == '[', "Bad field signature: '%s'", str); } else if (c == ')') { // for validation Assert.assertCondition(stack.pop() == '(', "Bad field signature: '%s'", str); } else if (c == ' ') { if (stack.isEmpty()) { // ensure outermost type parameters QualifiedIdentifier identifier = IdentifierUtil.makeIdentifier(str.substring(paramStartIdx, i), DefaultPolicy()); String typePart = str.substring(i + 1, str.length()); return new Field(identifier, decode(typePart)); } } } return null; }
public static boolean pastTM_Al(Stack s) { byte[] topElmt = ((Entry) s.peek()).getPart(); byte[] oldTopElmt = topElmt; if (BooleanMethod.endsWith_PastTMHuman_Al(topElmt)) { // clia.unl.unicode.utils.Utils.printOut(Analyser.print, x + "TM_Al"); s.pop(); s.push(new Entry(Constant.Al, Tag.ConditionalSuffix)); topElmt = ByteMeth.subArray(topElmt, 0, topElmt.length - Constant.Al.length); s.push(new Entry(topElmt, -1, oldTopElmt)); Tense.human(s); return true; } if (BooleanMethod.endsWith_PastTMHuman_Alum(topElmt)) { // clia.unl.unicode.utils.Utils.printOut(Analyser.print, x + "TM_Alum"); s.pop(); s.push(new Entry(Constant.um, Tag.Clitic)); s.push(new Entry(Constant.Al, Tag.ConditionalSuffix)); topElmt = ByteMeth.subArray(topElmt, 0, topElmt.length - Constant.Alum.length); s.push(new Entry(topElmt, -1, oldTopElmt)); Tense.human(s); return true; } return false; }
/** @see org.geotools.filter.FilterVisitor#visit(org.geotools.filter.FunctionExpression) */ public Object visit(Function expression, Object notUsed) { if (!fcs.supports(expression.getClass())) { postStack.push(expression); return null; } if (expression.getName() == null) { postStack.push(expression); return null; } int i = postStack.size(); int j = preStack.size(); for (int k = 0; k < expression.getParameters().size(); k++) { ((Expression) expression.getParameters().get(i)).accept(this, null); if (i < postStack.size()) { while (j < preStack.size()) preStack.pop(); postStack.pop(); postStack.push(expression); return null; } } while (j < preStack.size()) preStack.pop(); preStack.push(expression); return null; }
private boolean traverse(CallPosition callPos) { // make everything like it was before we returned previous match PatternPosition currentPos = callPos.getPatternPosition(); PatternRelationship pRel = callPos.getPatternRelationship(); pRel.mark(); visitedRels.remove(callPos.getLastVisitedRelationship()); Node currentNode = currentPos.getCurrentNode(); Iterator<Relationship> relItr = callPos.getRelationshipIterator(); while (relItr.hasNext()) { Relationship rel = relItr.next(); if (visitedRels.contains(rel)) { continue; } if (!checkProperties(pRel, rel)) { continue; } Node otherNode = rel.getOtherNode(currentNode); PatternNode otherPosition = pRel.getOtherNode(currentPos.getPatternNode()); pRel.mark(); visitedRels.add(rel); if (traverse(new PatternPosition(otherNode, otherPosition, pRel, rel, optional), true)) { callPos.setLastVisitedRelationship(rel); return true; } visitedRels.remove(rel); pRel.unMark(); } pRel.unMark(); if (callPos.shouldPopUncompleted()) { uncompletedPositions.pop(); } callStack.pop(); foundElements.pop(); return false; }
public void buildTree() { Stack<NodeStack> stack = new Stack<NodeStack>(); Block curr = firstData; Node root = null; long low = 0; while (curr != null) { root = curr; int level = 0; low = curr.keys[0]; while (stack.peek().level == level) { NodeStack lhsNode = stack.pop(); root = new InnerNode(low, lhsNode.node, root); low = lhsNode.low; level++; } curr = curr.next; } if (root != null) { while (!stack.empty()) { NodeStack lhsNode = stack.pop(); root = new InnerNode(low, lhsNode.node, root); low = lhsNode.low; } } }