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

1  
static L<Int> lineComp_replaceSublistWithUpdatingPairCount(L<Int> l, L<Int> x, L<Int> y, LineComp_PairCounts pairCounts) {
2  
  if (x == null) ret l;
3  
  
4  
  int i = 0;
5  
  while (true) {
6  
    i = indexOfSubList(l, x, i);
7  
    if (i < 0) break;
8  
    
9  
    int to = i+l(x), to_new = i+l(y);
10  
    ifdef lineComp_replaceSublistWithUpdatingPairCount_debug
11  
    print("Replacing " + subList(l, i, to) + " at " + i);
12  
    endifdef
13  
    
14  
    pairCounts.removeAll(overlappingIntPairs(subList(l, i-1, to+1)));
15  
    replaceSublist(l, i, to, y);
16  
    pairCounts.addAll(overlappingIntPairs(subList(l, i-1, to_new+1)));
17  
    i = to_new;
18  
  }
19  
  ret l;
20  
}

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