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

26
LINES

< > BotCompany Repo | #1028242 // lineComp_replacePairWithUpdatingPairCount_v2 - move elements ourselves

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

Libraryless. Click here for Pure Java version (3481L/22K).

1  
static L<Int> lineComp_replacePairWithUpdatingPairCount_v2(IContentsIndexedList2<Int> l, Int pa, Int pb, Int y, LineComp_PairCounts pairCounts) {
2  
  int i = 0, copyFrom = 0, copyTo = 0, n = l(l);
3  
  while (true) {
4  
    i = indexOfIntPairInContentsIndexedList(l, pa, pb, i);
5  
    if (i < 0) break;
6  
    
7  
    if (copyFrom != copyTo) {
8  
      while (copyFrom < i)
9  
        l.set(copyTo++, l.get(copyFrom++));
10  
    } else
11  
      copyTo = copyFrom = i;
12  
      
13  
    pairCounts.removeAll(overlappingIntPairs(subList(lineComp_listWithGap(l, copyTo, copyFrom), copyTo-1, copyTo+3)));
14  
    l.set(i, y);
15  
    copyFrom += 2;
16  
    copyTo++;
17  
    pairCounts.addAll(overlappingIntPairs(subList(lineComp_listWithGap(l, copyTo, copyFrom), copyTo-2, copyTo+1)));
18  
    i += 2;
19  
  }
20  
  if (copyFrom != copyTo) {
21  
    while (copyFrom < n)
22  
      l.set(copyTo++, l.get(copyFrom++));
23  
    truncateList(l, copyTo);
24  
  }
25  
  ret l;
26  
}

Author comment

Began life as a copy of #1028240

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: #1028242
Snippet name: lineComp_replacePairWithUpdatingPairCount_v2 - move elements ourselves
Eternal ID of this version: #1028242/10
Text MD5: 9d54ae766d497ef8d15ae1af375fec01
Transpilation MD5: 2cc03ae9606389d804de11dc92cd760b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-27 22:24:52
Source code size: 910 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 223 / 330
Version history: 9 change(s)
Referenced in: [show references]