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

20
LINES

< > BotCompany Repo | #1028216 // lineComp_replaceSublistWithUpdatingPairCount

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

Libraryless. Click here for Pure Java version (3464L/21K).

static L<Int> lineComp_replaceSublistWithUpdatingPairCount(L<Int> l, L<Int> x, L<Int> y, LineComp_PairCounts pairCounts) {
  if (x == null) ret l;
  
  int i = 0;
  while (true) {
    i = indexOfSubList(l, x, i);
    if (i < 0) break;
    
    int to = i+l(x), to_new = i+l(y);
    ifdef lineComp_replaceSublistWithUpdatingPairCount_debug
    print("Replacing " + subList(l, i, to) + " at " + i);
    endifdef
    
    pairCounts.removeAll(overlappingIntPairs(subList(l, i-1, to+1)));
    replaceSublist(l, i, to, y);
    pairCounts.addAll(overlappingIntPairs(subList(l, i-1, to_new+1)));
    i = to_new;
  }
  ret l;
}

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: #1028216
Snippet name: lineComp_replaceSublistWithUpdatingPairCount
Eternal ID of this version: #1028216/7
Text MD5: 29167fb732536fa3e80eeafaca421c9c
Transpilation MD5: 5f808e4c67ca6a4fb89f4737d7c374a7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-27 14:58:06
Source code size: 638 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 215 / 333
Version history: 6 change(s)
Referenced in: [show references]