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).

1  
static Map<S, L<Int>> lcRenumberTopLevelEncodings(LineCompCompressor lc, O... _) {
2  
  ret lcRenumberTopLevelEncodings(lc.finalEncodings, _);
3  
}
4  
5  
// out parameter: Map<Int> mapping (returns the forward mapping)
6  
static Map<S, L<Int>> lcRenumberTopLevelEncodings(Map<S, L<Int>> encodings, O... _) {
7  
  new LinkedHashMap<S, L<Int>> out;
8  
  new Map<Int> map;
9  
  setOutParameter(_, mapping := map);
10  
  for (S file, L<Int> l : encodings) {
11  
    new L<Int> l2;
12  
    for (int i : l) {
13  
      Int j = map.get(i);
14  
      if (j == null)
15  
        map.put(i, j = l(map)+1);
16  
      l2.add(j);
17  
    }
18  
    out.put(file, l2);
19  
  }
20  
  ret out;
21  
}

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: 121 / 197
Version history: 6 change(s)
Referenced in: [show references]