Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This piece of code is from my assignment and one of the condition was not to use arrays. In order to make the code more compact and readable you can use stringName.split("|"). Since the method is recursive I use the stringBuilder which has the following structure: "counter|orderOfElementToFind|dataInrequiredNode"</p> <pre><code>protected StringBuilder t(StringBuilder s) { if (lc != null) { lc.t(s); } if((s.toString().charAt(s.toString().length() - 1)) == '|') { String str = s.toString(); s.delete(0, s.length()); int counter = 0, k = 0; String strTemp = "", newStrBuilContent = ""; for (int i = 0, c = 0 ; i &lt; str.length(); ++i) { if (c == 0) { if (str.charAt(i) != '|') { strTemp += str.charAt(i); } else { counter = Integer.parseInt(strTemp); ++c; strTemp = ""; } } else { if (str.charAt(i) != '|') { strTemp += str.charAt(i); } else { k = Integer.parseInt(strTemp); } } counter ++; newStrBuilContent = (counter + "|" + k + "|"); s.append(newStrBuilContent); if (counter == k) { double ldata = this.getData(); s.append(ldata); } } if (rc != null) { rc.t(s); } return s; } </code></pre> <p>and the method call:</p> <pre><code>// the value of counter ad the beginning is 0 and data // segment is missing String s = ("0|" + order +"|"); StringBuilder strBldr = new StringBuilder(s); String content = sTree.t(strBldr).toString(); s = ""; for (int i = 0, c = 0; i &lt; content.length(); ++i) { if (c &lt; 2) { if (content.charAt(i) == '|') { ++c; } } else { s += content.charAt(i); } } ` </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload