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

13
LINES

< > BotCompany Repo | #1024612 // removeNonStreaksFromBitSetShorterThan

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

Libraryless. Click here for Pure Java version (38L/1K).

1  
svoid removeNonStreaksFromBitSetShorterThan(BitSet bs, int min) {
2  
  if (bs == null) ret;
3  
  int n = bs.length();
4  
  int i = -1;
5  
  while true {
6  
    i = bs.nextClearBit(i+1);
7  
    if (i >= n) break;
8  
    int j = bs.nextSetBit(i+1);
9  
    if (j-i < min)
10  
      bs.set(i, j, true);
11  
    i = j;
12  
  }
13  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024612
Snippet name: removeNonStreaksFromBitSetShorterThan
Eternal ID of this version: #1024612/5
Text MD5: 6b612794ed74b95156019302c668309d
Transpilation MD5: 8c59e81e2406b0f9330f1e0f809f7083
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-20 00:22:14
Source code size: 299 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 197 / 296
Version history: 4 change(s)
Referenced in: [show references]