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

12
LINES

< > BotCompany Repo | #1019223 // invertIntRanges - return holes as ranges

JavaX fragment (include)

1  
static L<IntRange> invertIntRanges(L<IntRange> l, int start, int end) {
2  
  new L<IntRange> out;
3  
  int x = start, i = 0;
4  
  while (i < l(l)) {
5  
    int y = l.get(i).start;
6  
    if (y > x) out.add(intRange(x, y));
7  
    x = l.get(i).end;
8  
    ++i;
9  
  }
10  
  if (end > x) out.add(intRange(x, end));
11  
  ret out;
12  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019223
Snippet name: invertIntRanges - return holes as ranges
Eternal ID of this version: #1019223/1
Text MD5: c628d5cfdca6d922c898c40f77c203fb
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-28 00:47:38
Source code size: 308 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 301 / 348
Referenced in: [show references]