Libraryless. Click here for Pure Java version (6181L/37K).
1 | //set flag JSONSpecialIntegral_debug. |
2 | |
3 | svoid test_JSONSpecialIntegral() { |
4 | new JSONSpecialIntegral integral; |
5 | integral.analyze([[{"abcdefghijklmnop": "abcdefghijklmnopq", "abcdefghijklmnopq": ["abc","abcdefghijklmnop"]}]]); |
6 | print(integral.stats()); |
7 | print(sfuWithIndent(1, integral)); |
8 | int n = integral.n(); |
9 | |
10 | embedded void descend(int i, int iEnd, int remainingDepth) { |
11 | printVars descend(i, iEnd, remainingDepth); |
12 | if (i >= iEnd || remainingDepth <= 0) ret; // out of characters or depth |
13 | |
14 | // bracket level at start, bracket level at end |
15 | |
16 | int lvlLeft = integral.bracketLevel(i-1); |
17 | int lvlRight = integral.bracketLevel(iEnd-1); |
18 | |
19 | // count at start, count at end |
20 | |
21 | int cntLeft = integral.bracketCount(i-1); |
22 | int cntRight = integral.bracketCount(iEnd-1); |
23 | int brackets = cntRight-cntLeft; |
24 | |
25 | print("Brackets in range " + i + " to " + iEnd + ": " + brackets); |
26 | if (brackets == 0) ret; |
27 | |
28 | int iMid = (i+iEnd) >> 1; |
29 | descend(i, i, iMid); |
30 | descend(i, iMid, iEnd); |
31 | } |
32 | |
33 | int lvl = integral.bracketLevel(n-1); |
34 | if (lvl != 0) |
35 | fail("Bad brackets: level at end is " + lvl); |
36 | |
37 | int depth = 1; |
38 | descend(0, n, depth); |
39 | } |
Began life as a copy of #1032590
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032594 |
Snippet name: | test_JSONSpecialIntegral [dev.] |
Eternal ID of this version: | #1032594/15 |
Text MD5: | 1636594e74c3872a252ec71f315f408b |
Transpilation MD5: | ca38c888e498204d1adf87d87558637c |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-23 10:05:23 |
Source code size: | 1229 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 146 / 252 |
Version history: | 14 change(s) |
Referenced in: | [show references] |