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

16
LINES

< > BotCompany Repo | #1030965 // bitSetStreaksAndNonStreaks

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

Libraryless. Click here for Pure Java version (2839L/17K).

1  
static LPair<IntRange, Bool> bitSetStreaksAndNonStreaks(BitSet bs, int n) {
2  
  int start = 0;
3  
  Bool last = null;
4  
  new LPair<IntRange, Bool> out;
5  
  for i to n: {
6  
    Bool result = bs.get(i);
7  
    if (last != null && neq(result, last)) {
8  
      out.add(pair(intRange(start, i), last));
9  
      start = i;
10  
    }
11  
    last = result;
12  
  }
13  
  if (start < n)
14  
    out.add(pair(intRange(start, n), last));
15  
  ret out; 
16  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030965
Snippet name: bitSetStreaksAndNonStreaks
Eternal ID of this version: #1030965/2
Text MD5: 19e8baa541d04c5718f0915cff8c6a70
Transpilation MD5: 4ddf329b7f8109e4bc618ed1c3de0d4e
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-16 15:11:24
Source code size: 419 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 156 / 231
Version history: 1 change(s)
Referenced in: [show references]