Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

28
LINES

< > BotCompany Repo | #1031202 // renderLineCompedSingleLevels_raw_v2

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2977L/18K).

scope renderLineCompedSingleLevels_raw_v2.

static int[][] renderLineCompedSingleLevels_raw_v2(LineCompedSingle<Char> lc) {
  int n = lcLength(lc);
  
  // each matrix element is the symbol starting position for the character+1 (or 0 for empty)
  L<int[]> rows = new AutoCreateList<>(() -> new int[n]);
  fill(lc, rows, 0, 0, lc.main);
  ret toArray(rows, int[].class);
}
  
// returns new x
static int #fill(LineCompedSingle<Char> lc, L<int[]> rows, int x, int y, L<Int> symbols) {
  //printVars_str fill(+x, +y, +symbols);
  for (int idx : symbols) {
    if (idx < l(lc.literals)) {
      rows.get(y)[x] = x+1;
      x++;
    } else {
      int newX = fill(lc, rows, x, y+1, intPairToList(lc.getPair(idx)));
      int x1 = x;
      while (x < newX) rows.get(y)[x++] = x1+1;
    }
  }
  ret x;
}

end scope

Author comment

Began life as a copy of #1031200

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031202
Snippet name: renderLineCompedSingleLevels_raw_v2
Eternal ID of this version: #1031202/6
Text MD5: b21b3ec932c49056153c7c8966c2da13
Transpilation MD5: da61bdacd66aac5765be555839442872
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-20 15:14:32
Source code size: 834 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 126 / 190
Version history: 5 change(s)
Referenced in: [show references]