/** {@inheritDoc} */ public String print() { StringBuilder buffer = new StringBuilder("("); buffer.append(left.print()); buffer.append(' '); buffer.append(symbol); buffer.append(' '); buffer.append(right.print()); buffer.append(')'); return buffer.toString(); }
public void print(String prefix) { if (isLeaf()) { int bestLabelIndex = getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * getSize()); System.out.println( "root:" + getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + getSize()); } else { String featName = m_dataDict.lookupObject(getGainRatio().getMaxValuedIndex()).toString(); double threshold = getGainRatio().getMaxValuedThreshold(); System.out.print(prefix + "\"" + featName + "\" <= " + threshold + ":"); if (m_leftChild.isLeaf()) { int bestLabelIndex = m_leftChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_leftChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_leftChild.getSize()); System.out.println( m_leftChild.getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + m_leftChild.getSize()); } else { System.out.println(); m_leftChild.print(prefix + "| "); } System.out.print(prefix + "\"" + featName + "\" > " + threshold + ":"); if (m_rightChild.isLeaf()) { int bestLabelIndex = m_rightChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_rightChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_rightChild.getSize()); System.out.println( m_rightChild.getGainRatio().getBaseLabelDistribution().getBestLabel() + " " + numMajorityLabel + "/" + m_rightChild.getSize()); } else { System.out.println(); m_rightChild.print(prefix + "| "); } } }
void print(Node t, int n, boolean p) { if (p) { t.print(n, true); } else { if (n > 0) { for (int i = 0; i < n; i++) System.out.print(" "); } System.out.print("("); if (t.isPair() && t.getCdr() != null) { t.getCar().print(n, true); t.getCdr().print(-n, true); } else if (!t.isPair()) t.print(-n, true); else System.err.println("Null Pointer"); } }
public static void printSubsequentIndented(Node t, int n, boolean p) { if (t == null) return; while (t != null) { // remove t.car.car check to make it print like the provided binary if (t.car instanceof Cons && t.car.car instanceof Cons) { printIndentation(n); System.out.printf(t.car.toString()); System.out.printf("\n"); printSubsequentIndented(t.car, n + Constants.INDENTATION, p); } else if (t instanceof Nil) { int newIndentation = n - Constants.INDENTATION; printIndentation(newIndentation); t.print(newIndentation, p); System.out.printf("\n"); } else { printIndentation(n); if (t.car instanceof Nil) { t.car.print(n, false); } else { t.car.print(n, p); } System.out.printf("\n"); } t = t.cdr; } }
void print(Node t, int n, boolean p) { if (p == false) { System.out.print("("); } System.out.print("let"); // print inside stuff indented Node c = t.getCdr(); if (c.isNull()) { c.print(0, true); } else if (c.isPair()) { c.print((n - (n % 4)) + 4, true); } else { System.out.print('.'); c.print(0, false); System.out.print(')'); } }
public static void printFirstElementOnSameLine(Node t, int n, boolean p) { Node firstLine = t.cdr.car; firstLine.print(n, p); System.out.printf("\n"); Node secondLine = t.cdr.cdr; n += Constants.INDENTATION; printSubsequentIndented(secondLine, n, p); }
// after tree created, can print it. private void printSubTree(Node n) { // now post order if (n.children != null) { for (Node child : n.children) { printSubTree(child); } } // System.out.println (""); n.print(); }
@Override public String toString() { StringWriter sw = new StringWriter(); IndentWriter iw = new IndentWriter(sw); try { fRoot.print(iw); return sw.toString(); } catch (IOException e) { throw new RuntimeException(e); } }
public DistMutEx(int my_id) { this.my_id = my_id; // Reading Config file try { rfile = new Scanner(new File("Config.txt")); while (rfile.hasNextLine()) { rline = rfile.nextLine(); if (rline.charAt(0) != '#') { // Skipping the first line of input, Which has only the // count of the nodes if (valcn == 0) { num_nodes = Character.getNumericValue(rline.charAt(0)); valcn = 1; rline = rfile.nextLine(); } String[] params = rline.split(" "); Node temp = new Node(params[0], params[1], params[2]); temp.print(); nodes.put(params[0], temp); } } // Initializing the Token object token = new Token(num_nodes); // Initializing the RN array RN = new int[DistMutEx.nodes.size()]; // Initializing RN for (int i = 0; i < DistMutEx.nodes.size(); i++) { RN[i] = -1; } // IF the node id is 0, Hold the token for initial if (my_id == 0) { hastoken = true; } // Starting MutEx thread to accept requests p = Integer.parseInt(nodes.get(Integer.toString(my_id)).port); mutexRecvReqThread = new MutexReqRec(p); mutexRecvReqThread.start(); rfile.close(); } catch (IOException e) { rfile.close(); e.printStackTrace(); } }
@Override public void print(String prefix) { System.out.println(prefix + nodeType); for (Node node : children) node.print(prefix + "\t"); }
public void printAlt(String padding) { // StrOperator = StrOperator + program.getText(); field.print("\t"); method.print("\t"); }
public void print(String padding) { // StrOperator = StrOperator + program.getText(); System.out.println(program.getText()); field.print("\t"); method.print("\t"); }
public void print() { root.print(""); }