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

21
LINES

< > BotCompany Repo | #1028771 // lcRenumberTopLevelEncodings - starts counting at 1, just for fun

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

Uses 11335K of libraries. Click here for Pure Java version (7927L/51K).

static Map<S, L<Int>> lcRenumberTopLevelEncodings(LineCompCompressor lc, O... _) {
  ret lcRenumberTopLevelEncodings(lc.finalEncodings, _);
}

// out parameter: Map<Int> mapping (returns the forward mapping)
static Map<S, L<Int>> lcRenumberTopLevelEncodings(Map<S, L<Int>> encodings, O... _) {
  new LinkedHashMap<S, L<Int>> out;
  new Map<Int> map;
  setOutParameter(_, mapping := map);
  for (S file, L<Int> l : encodings) {
    new L<Int> l2;
    for (int i : l) {
      Int j = map.get(i);
      if (j == null)
        map.put(i, j = l(map)+1);
      l2.add(j);
    }
    out.put(file, l2);
  }
  ret out;
}

Author comment

Began life as a copy of #1028765

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028771
Snippet name: lcRenumberTopLevelEncodings - starts counting at 1, just for fun
Eternal ID of this version: #1028771/7
Text MD5: feca6f190498f1ccb7b76cc6664bfb93
Transpilation MD5: fbd364d8e0ffdd6ca98d00acfa0bf54e
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-08 15:35:36
Source code size: 631 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 220 / 316
Version history: 6 change(s)
Referenced in: [show references]