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

static L<Int> lineComp_replacePairWithUpdatingPairCount_v2(IContentsIndexedList2<Int> l, Int pa, Int pb, Int y, LineComp_PairCounts pairCounts) {
  int i = 0, copyFrom = 0, copyTo = 0, n = l(l);
  while (true) {
    i = indexOfIntPairInContentsIndexedList(l, pa, pb, i);
    if (i < 0) break;
    
    if (copyFrom != copyTo) {
      while (copyFrom < i)
        l.set(copyTo++, l.get(copyFrom++));
    } else
      copyTo = copyFrom = i;
      
    pairCounts.removeAll(overlappingIntPairs(subList(lineComp_listWithGap(l, copyTo, copyFrom), copyTo-1, copyTo+3)));
    l.set(i, y);
    copyFrom += 2;
    copyTo++;
    pairCounts.addAll(overlappingIntPairs(subList(lineComp_listWithGap(l, copyTo, copyFrom), copyTo-2, copyTo+1)));
    i += 2;
  }
  if (copyFrom != copyTo) {
    while (copyFrom < n)
      l.set(copyTo++, l.get(copyFrom++));
    truncateList(l, copyTo);
  }
  ret l;
}

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: 222 / 327
Version history: 9 change(s)
Referenced in: [show references]