Libraryless. Click here for Pure Java version (3365L/21K).
ifclass LineCompCompressor static LCLongerProds lcSimplifyToLongerProductions(LineCompCompressor comp) { ret lcSimplifyToLongerProductions( map(countIterator_exclusive(0, comp.nLiterals()), i -> comp.itemToString(i)), map(countIterator_exclusive(comp.nLiterals(), comp.nItems()), i -> comp.getPair(i)), comp.finalEncodings); } endif static LCLongerProds lcSimplifyToLongerProductions(LS literals, L<IntPair> pairs, Map<S, L<Int>> files) { new LCLongerProds lc; lc.literals = literals; int nLiterals = l(literals); for i over pairs: lc.productions.put(nLiterals+i, intPairToList(pairs.get(i))); lc.files = mapValues cloneList(files); bool change; do { ping(); change = false; new MultiSet<Int> counts; for (L<Int> l : concatLists(values(lc.productions), values(lc.files))) for (int i : l) if (i >= nLiterals) counts.add(i); for (int i : cloneList(counts.asSet())) if (counts.get(i) == 1) { set change; L<Int> unrolled = assertNotNull(lc.productions.get(i)); print("Unrolling " + i + " => " + unrolled); lc.productions.remove(i); counts.remove(i); for (L<Int> l : concatLists(values(lc.productions), values(lc.files))) replaceSublist(l, ll(i), unrolled); } } while (change); ret lc; }
Began life as a copy of #1028777
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: | #1028856 |
Snippet name: | lcSimplifyToLongerProductions |
Eternal ID of this version: | #1028856/10 |
Text MD5: | ff0d66af34510d95ffc7820dea15bd04 |
Transpilation MD5: | 57dda7a739315b755a3e876c7f192baf |
Author: | stefan |
Category: | javax / linecomp |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-10 13:57:23 |
Source code size: | 1374 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 253 / 351 |
Version history: | 9 change(s) |
Referenced in: | [show references] |